mirror of
https://github.com/strapi/strapi.git
synced 2025-11-29 08:36:24 +00:00
Cast only for filters that require it
This commit is contained in:
parent
f73d302129
commit
674acadcc6
@ -29,6 +29,19 @@ const OPERATORS = [
|
|||||||
'$notContainsi',
|
'$notContainsi',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const CAST_OPERATORS = [
|
||||||
|
'$not',
|
||||||
|
'$in',
|
||||||
|
'$notIn',
|
||||||
|
'$eq',
|
||||||
|
'$ne',
|
||||||
|
'$gt',
|
||||||
|
'$gte',
|
||||||
|
'$lt',
|
||||||
|
'$lte',
|
||||||
|
'$between',
|
||||||
|
];
|
||||||
|
|
||||||
const ARRAY_OPERATORS = ['$in', '$notIn', '$between'];
|
const ARRAY_OPERATORS = ['$in', '$notIn', '$between'];
|
||||||
|
|
||||||
const isOperator = key => OPERATORS.includes(key);
|
const isOperator = key => OPERATORS.includes(key);
|
||||||
@ -62,6 +75,15 @@ const processAttributeWhere = (attribute, where, ctx) => {
|
|||||||
const value = where[key];
|
const value = where[key];
|
||||||
|
|
||||||
if (isOperator(key)) {
|
if (isOperator(key)) {
|
||||||
|
if (!_.isPlainObject(value)) {
|
||||||
|
if (CAST_OPERATORS.includes(key)) {
|
||||||
|
filters[key] = castValue(value, attribute);
|
||||||
|
} else {
|
||||||
|
filters[key] = value;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
filters[key] = processAttributeWhere(attribute, value, ctx);
|
filters[key] = processAttributeWhere(attribute, value, ctx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user