Skip to content

Commit

Permalink
fix filter breaking instead of defaulting to _eq (#10194)
Browse files Browse the repository at this point in the history
  • Loading branch information
azrikahar committed Dec 1, 2021
1 parent 481d03d commit 648b2d0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/shared/src/utils/parse-filter.ts
Expand Up @@ -3,6 +3,7 @@ import { Accountability, Filter, User, Role } from '../types';
import { toArray } from './to-array';
import { adjustDate } from './adjust-date';
import { isDynamicVariable } from './is-dynamic-variable';
import { isObjectLike } from 'lodash';

type ParseFilterContext = {
// The user can add any custom fields to user
Expand All @@ -16,6 +17,7 @@ export function parseFilter(
context: ParseFilterContext = {}
): Filter | null {
if (!filter) return null;
if (!isObjectLike(filter)) return filter;
return Object.entries(filter).reduce((result, [key, value]) => {
if (['_or', '_and'].includes(String(key))) {
result[key] = value.map((filter: Filter) => parseFilter(filter, accountability, context));
Expand Down

0 comments on commit 648b2d0

Please sign in to comment.