Skip to content

Commit

Permalink
fix(core): support operators in json property queries
Browse files Browse the repository at this point in the history
Closes #1487
  • Loading branch information
B4nan committed Feb 25, 2021
1 parent 6eed553 commit cb5e715
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/utils/QueryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class QueryHelper {
}

private static processJsonCondition<T>(o: FilterQuery<T>, value: Dictionary, path: string[], platform: Platform) {
if (Utils.isPlainObject(value)) {
if (Utils.isPlainObject(value) && !Object.keys(value).some(k => Utils.isOperator(k))) {
Object.keys(value).forEach(k => {
this.processJsonCondition(o, value[k], [...path, k], platform);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/EntityManager.postgre.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ describe('EntityManagerPostgre', () => {
orm.em.clear();

const b1 = await orm.em.findOneOrFail(Book2, { meta: { category: 'god like' } });
const b2 = await orm.em.findOneOrFail(Book2, { meta: { category: 'god like', items: 3 } });
const b2 = await orm.em.findOneOrFail(Book2, { meta: { category: { $in: ['god like'] }, items: 3 } }); // supports operators (GH #1487)
const b3 = await orm.em.findOneOrFail(Book2, { meta: { nested: { bar: 321 } } });
const b4 = await orm.em.findOneOrFail(Book2, { meta: { nested: { foo: '123', bar: 321 } } });
const b5 = await orm.em.findOneOrFail(Book2, { meta: { valid: true, nested: { foo: '123', bar: 321 } } });
Expand Down

0 comments on commit cb5e715

Please sign in to comment.