mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 22:54:31 +00:00
Fix undefined filter value (#8490)
* Fix undefined filter value Fixes #8201 Signed-off-by: MattieBelt <mattiasvandenbelt@gmail.com> * Move isNil() before .map() & update error message Fixes #8201 Signed-off-by: MattieBelt <mattiasvandenbelt@gmail.com> * Fix allowing to find null values Signed-off-by: MattieBelt <mattiasvandenbelt@gmail.com> Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com>
This commit is contained in:
parent
53c7fb0970
commit
23ead26f94
@ -111,8 +111,16 @@ const hasDeepFilters = ({ where = [], sort = [] }, { minDepth = 1 } = {}) => {
|
||||
|
||||
const normalizeWhereClauses = (whereClauses, { model }) => {
|
||||
return whereClauses
|
||||
.filter(({ value }) => !_.isNil(value))
|
||||
.filter(({ value }) => !_.isNull(value))
|
||||
.map(({ field, operator, value }) => {
|
||||
if (_.isUndefined(value)) {
|
||||
const err = new Error(
|
||||
`The value of field: '${field}', in your where filter, is undefined.`
|
||||
);
|
||||
err.status = 400;
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (BOOLEAN_OPERATORS.includes(operator)) {
|
||||
return {
|
||||
field,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user