-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Make
Criteria#contains(value)
work as expected on array fields
- Loading branch information
Showing
2 changed files
with
16 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,7 @@ | |
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
var NoSQL = Function.inherits('Alchemy.Datasource', function Nosql(name, options) { | ||
Nosql.super.call(this, name, options); | ||
}); | ||
var NoSQL = Function.inherits('Alchemy.Datasource', 'Nosql'); | ||
|
||
/** | ||
* All comparison functions | ||
|
@@ -590,7 +588,7 @@ NoSQL.setStatic(function areComparable(a, b) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.3.16 | ||
* @version 1.4.0 | ||
* | ||
* @param {Criteria} criteria | ||
* @param {Group} group | ||
|
@@ -765,7 +763,19 @@ NoSQL.setMethod(function compileCriteria(criteria, group) { | |
} else if (item.type == 'equals') { | ||
obj = item.value; | ||
} else if (item.type == 'contains') { | ||
obj = RegExp.interpret(item.value); | ||
|
||
let do_regexp_search = true; | ||
|
||
if (entry.field) { | ||
if (entry.field.is_array || entry.field.options?.type == 'HasAndBelongsToMany') { | ||
do_regexp_search = false; | ||
obj = item.value; | ||
} | ||
} | ||
|
||
if (do_regexp_search) { | ||
obj = RegExp.interpret(item.value); | ||
} | ||
} else if (item.type == 'in') { | ||
|
||
// @TODO: This shouldn't be needed, | ||
|