Skip to content

Commit

Permalink
fix: missing modifier queries were inverted (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshah-asymmetrik committed Jun 5, 2019
1 parent 0f6aeb2 commit ba6eba7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/fhir-qb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class QueryBuilder {
// If the modifier is 'missing', nothing else matters, we're just checking if the field exists.
if (modifier === matchModifiers.missing) {
value = sanitize.sanitizeBoolean({ field, value });
subQuery = this.qb.buildExistsQuery({ field, exists: value });
subQuery = this.qb.buildExistsQuery({ field, exists: !value });
} else {
// Otherwise, construct a query based on data type
switch (type) {
Expand Down
4 changes: 2 additions & 2 deletions packages/fhir-qb/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4641,7 +4641,7 @@ describe('Mongo Tests', () => {
includeArchived,
});
const expectedResult = [
{ $match: { $and: [{ $or: [{ foo: { $exists: true } }] }] } },
{ $match: { $and: [{ $or: [{ foo: { $exists: false } }] }] } },
{ $match: { 'meta._isArchived': false } },
{
$facet: {
Expand Down Expand Up @@ -4678,7 +4678,7 @@ describe('Mongo Tests', () => {
includeArchived,
});
const expectedResult = [
{ $match: { $and: [{ $or: [{ foo: { $exists: false } }] }] } },
{ $match: { $and: [{ $or: [{ foo: { $exists: true } }] }] } },
{ $match: { 'meta._isArchived': false } },
{
$facet: {
Expand Down

0 comments on commit ba6eba7

Please sign in to comment.