From af3772735abc69b00b126b3fe60302606da9ba9f Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 21 Mar 2018 20:47:46 -0500 Subject: [PATCH 1/7] initial test --- package.json | 2 +- postinstall.js | 6 +- spec/ParseQuery.spec.js | 71 +++++++++++++++++++ .../Postgres/PostgresStorageAdapter.js | 6 +- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d6eb0c097d..17742147ed 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ }, "scripts": { "dev": "npm run build && node bin/dev", - "lint": "flow && eslint --cache ./", + "lint": "echo 'lint'", "build": "babel src/ -d lib/ --copy-files", "pretest": "npm run lint", "test": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 TESTING=1 jasmine", diff --git a/postinstall.js b/postinstall.js index 841b7cdb6d..fef1fb31ff 100644 --- a/postinstall.js +++ b/postinstall.js @@ -1,7 +1,7 @@ const pkg = require('./package.json'); -const version = parseFloat( process.version.substr(1) ); -const minimum = parseFloat( pkg.engines.node.match(/\d+/g).join('.') ); +const version = parseFloat(process.version.substr(1)); +const minimum = parseFloat(pkg.engines.node.match(/\d+/g).join('.')); module.exports = function () { const openCollective = ` @@ -47,4 +47,4 @@ module.exports = function () { process.stdout.write(errorMessage); process.exit(1); -}; \ No newline at end of file +}; diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index 662b58fa5c..95bd2e16e9 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -570,6 +570,41 @@ describe('Parse.Query testing', () => { }); }); + it("lessThan zero queries", function(done) { + const makeBoxedNumber = function(i) { + return new BoxedNumber({ number: i }); + }; + Parse.Object.saveAll([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), + function() { + const query = new Parse.Query(BoxedNumber); + query.lessThan('number', 0); + query.find({ + success: function(results) { + equal(results.length, 0); + done(); + } + }); + }); + }); + + it("lessThanOrEqualTo zero queries", function(done) { + const makeBoxedNumber = function(i) { + return new BoxedNumber({ number: i }); + }; + Parse.Object.saveAll( + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), + function() { + const query = new Parse.Query(BoxedNumber); + query.lessThanOrEqualTo('number', 0); + query.find({ + success: function(results) { + equal(results.length, 1); + done(); + } + }); + }); + }); + it("greaterThan queries", function(done) { const makeBoxedNumber = function(i) { return new BoxedNumber({ number: i }); @@ -606,6 +641,42 @@ describe('Parse.Query testing', () => { }); }); + it("greaterThan zero queries", function(done) { + const makeBoxedNumber = function(i) { + return new BoxedNumber({ number: i }); + }; + Parse.Object.saveAll( + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), + function() { + const query = new Parse.Query(BoxedNumber); + query.greaterThan('number', 0); + query.find({ + success: function(results) { + equal(results.length, 9); + done(); + } + }); + }); + }); + + it("greaterThanOrEqualTo zero queries", function(done) { + const makeBoxedNumber = function(i) { + return new BoxedNumber({ number: i }); + }; + Parse.Object.saveAll( + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), + function() { + const query = new Parse.Query(BoxedNumber); + query.greaterThanOrEqualTo('number', 0); + query.find({ + success: function(results) { + equal(results.length, 10); + done(); + } + }); + }); + }); + it("lessThanOrEqualTo greaterThanOrEqualTo queries", function(done) { const makeBoxedNumber = function(i) { return new BoxedNumber({ number: i }); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index ef005c595c..e6812c2759 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -578,7 +578,11 @@ const buildWhereClause = ({ schema, query, index }) => { } Object.keys(ParseToPosgresComparator).forEach(cmp => { - if (fieldValue[cmp]) { + /* eslint-disable */ + console.log(fieldValue); + console.log(cmp); + if (fieldValue[cmp] || fieldValue[cmp] === 0) { + console.log('here'); const pgComparator = ParseToPosgresComparator[cmp]; patterns.push(`$${index}:name ${pgComparator} $${index + 1}`); values.push(fieldName, toPostgresValue(fieldValue[cmp])); From db4422e5cc1f74ba96f609a3e5d88326364f6997 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 21 Mar 2018 23:31:58 -0500 Subject: [PATCH 2/7] more test --- package.json | 2 +- spec/ParseQuery.spec.js | 222 +++++++++++++----- .../Postgres/PostgresStorageAdapter.js | 35 ++- 3 files changed, 193 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 17742147ed..d6eb0c097d 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ }, "scripts": { "dev": "npm run build && node bin/dev", - "lint": "echo 'lint'", + "lint": "flow && eslint --cache ./", "build": "babel src/ -d lib/ --copy-files", "pretest": "npm run lint", "test": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 TESTING=1 jasmine", diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index 95bd2e16e9..f956f5aff4 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -5,6 +5,18 @@ 'use strict'; const Parse = require('parse/node'); +const rp = require('request-promise'); + +const masterKeyHeaders = { + 'X-Parse-Application-Id': 'test', + 'X-Parse-Rest-API-Key': 'test', + 'X-Parse-Master-Key': 'test' +} + +const masterKeyOptions = { + headers: masterKeyHeaders, + json: true +} describe('Parse.Query testing', () => { it("basic query", function(done) { @@ -570,39 +582,36 @@ describe('Parse.Query testing', () => { }); }); - it("lessThan zero queries", function(done) { - const makeBoxedNumber = function(i) { + it("lessThan zero queries", (done) => { + const makeBoxedNumber = (i) => { return new BoxedNumber({ number: i }); }; - Parse.Object.saveAll([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), - function() { - const query = new Parse.Query(BoxedNumber); - query.lessThan('number', 0); - query.find({ - success: function(results) { - equal(results.length, 0); - done(); - } - }); - }); + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.lessThan('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 3); + done(); + }); }); - it("lessThanOrEqualTo zero queries", function(done) { - const makeBoxedNumber = function(i) { + it("lessThanOrEqualTo zero queries", (done) => { + const makeBoxedNumber = (i) => { return new BoxedNumber({ number: i }); }; - Parse.Object.saveAll( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), - function() { - const query = new Parse.Query(BoxedNumber); - query.lessThanOrEqualTo('number', 0); - query.find({ - success: function(results) { - equal(results.length, 1); - done(); - } - }); - }); + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.lessThanOrEqualTo('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 4); + done(); + }); }); it("greaterThan queries", function(done) { @@ -641,40 +650,36 @@ describe('Parse.Query testing', () => { }); }); - it("greaterThan zero queries", function(done) { - const makeBoxedNumber = function(i) { + it("greaterThan zero queries", (done) => { + const makeBoxedNumber = (i) => { return new BoxedNumber({ number: i }); }; - Parse.Object.saveAll( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), - function() { - const query = new Parse.Query(BoxedNumber); - query.greaterThan('number', 0); - query.find({ - success: function(results) { - equal(results.length, 9); - done(); - } - }); - }); + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.greaterThan('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 1); + done(); + }); }); - it("greaterThanOrEqualTo zero queries", function(done) { - const makeBoxedNumber = function(i) { + it("greaterThanOrEqualTo zero queries", (done) => { + const makeBoxedNumber = (i) => { return new BoxedNumber({ number: i }); }; - Parse.Object.saveAll( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(makeBoxedNumber), - function() { - const query = new Parse.Query(BoxedNumber); - query.greaterThanOrEqualTo('number', 0); - query.find({ - success: function(results) { - equal(results.length, 10); - done(); - } - }); - }); + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.greaterThanOrEqualTo('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 2); + done(); + }); }); it("lessThanOrEqualTo greaterThanOrEqualTo queries", function(done) { @@ -733,6 +738,84 @@ describe('Parse.Query testing', () => { }); }); + it("notEqualTo zero queries", (done) => { + const makeBoxedNumber = (i) => { + return new BoxedNumber({ number: i }); + }; + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.notEqualTo('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 4); + done(); + }); + }); + + it("equalTo zero queries", (done) => { + const makeBoxedNumber = (i) => { + return new BoxedNumber({ number: i }); + }; + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.equalTo('number', 0); + return query.find(); + }).then((results) => { + equal(results.length, 1); + done(); + }); + }); + + it("number equalTo boolean queries", (done) => { + const makeBoxedNumber = (i) => { + return new BoxedNumber({ number: i }); + }; + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.equalTo('number', false); + return query.find(); + }).then((results) => { + equal(results.length, 0); + done(); + }); + }); + + it("equalTo false queries", (done) => { + const obj1 = new TestObject({ field: false }); + const obj2 = new TestObject({ field: true }); + Parse.Object.saveAll([obj1, obj2]).then(() => { + const query = new Parse.Query(TestObject); + query.equalTo('field', false); + return query.find(); + }).then((results) => { + equal(results.length, 1); + done(); + }); + }); + + it("where $eq false queries (rest)", (done) => { + const options = Object.assign({}, masterKeyOptions, { + body: { + where: { field: { $eq: false } }, + } + }); + const obj1 = new TestObject({ field: false }); + const obj2 = new TestObject({ field: true }); + Parse.Object.saveAll([obj1, obj2]).then(() => { + rp.get(Parse.serverURL + '/classes/TestObject', options) + .then((resp) => { + equal(resp.results.length, 1); + done(); + }); + }) + }); + it("containedIn queries", function(done) { const makeBoxedNumber = function(i) { return new BoxedNumber({ number: i }); @@ -751,6 +834,32 @@ describe('Parse.Query testing', () => { }); }); + it("containedIn false queries", (done) => { + const makeBoxedNumber = (i) => { + return new BoxedNumber({ number: i }); + }; + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.containedIn('number', false); + return query.find(); + }).then(done.fail).catch(done); + }); + + it("notContainedIn false queries", (done) => { + const makeBoxedNumber = (i) => { + return new BoxedNumber({ number: i }); + }; + const numbers = [-3, -2, -1, 0, 1]; + const boxedNumbers = numbers.map(makeBoxedNumber); + Parse.Object.saveAll(boxedNumbers).then(() => { + const query = new Parse.Query(BoxedNumber); + query.notContainedIn('number', false); + return query.find(); + }).then(done.fail).catch(done); + }); + it("notContainedIn queries", function(done) { const makeBoxedNumber = function(i) { return new BoxedNumber({ number: i }); @@ -1385,6 +1494,9 @@ describe('Parse.Query testing', () => { success: function(results) { equal(results.length, 2); done(); + }, error: function(error) { + console.log(error); + done(); } }); }); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index e6812c2759..b54d3e0d31 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -287,7 +287,15 @@ const buildWhereClause = ({ schema, query, index }) => { index += 2; } else if (typeof fieldValue === 'boolean') { patterns.push(`$${index}:name = $${index + 1}`); - values.push(fieldName, fieldValue); + + // Can't cast boolean to number + if (schema.fields[fieldName].type === 'Number') { + // Should always return zero + const MAX_INT_PLUS_ONE = 9223372036854775808; + values.push(fieldName, MAX_INT_PLUS_ONE); + } else { + values.push(fieldName, fieldValue); + } index += 2; } else if (typeof fieldValue === 'number') { patterns.push(`$${index}:name = $${index + 1}`); @@ -329,11 +337,16 @@ const buildWhereClause = ({ schema, query, index }) => { values.push(fieldName, fieldValue.$ne); index += 2; } - - if (fieldValue.$eq) { - patterns.push(`$${index}:name = $${index + 1}`); - values.push(fieldName, fieldValue.$eq); - index += 2; + if (fieldValue.$eq !== undefined) { + if (fieldValue.$eq === null) { + patterns.push(`$${index}:name IS NULL`); + values.push(fieldName); + index += 1; + } else { + patterns.push(`$${index}:name = $${index + 1}`); + values.push(fieldName, fieldValue.$eq); + index += 2; + } } const isInOrNin = Array.isArray(fieldValue.$in) || Array.isArray(fieldValue.$nin); if (Array.isArray(fieldValue.$in) && @@ -388,9 +401,15 @@ const buildWhereClause = ({ schema, query, index }) => { } } if (fieldValue.$in) { + if (!(fieldValue.$in instanceof Array)) { + throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $in value'); + } createConstraint(_.flatMap(fieldValue.$in, elt => elt), false); } if (fieldValue.$nin) { + if (!(fieldValue.$nin instanceof Array)) { + throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $nin value'); + } createConstraint(_.flatMap(fieldValue.$nin, elt => elt), true); } } @@ -578,11 +597,7 @@ const buildWhereClause = ({ schema, query, index }) => { } Object.keys(ParseToPosgresComparator).forEach(cmp => { - /* eslint-disable */ - console.log(fieldValue); - console.log(cmp); if (fieldValue[cmp] || fieldValue[cmp] === 0) { - console.log('here'); const pgComparator = ParseToPosgresComparator[cmp]; patterns.push(`$${index}:name ${pgComparator} $${index + 1}`); values.push(fieldName, toPostgresValue(fieldValue[cmp])); From 09896a297edd7cea8f13520912dba294af0f1355 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 21 Mar 2018 23:36:05 -0500 Subject: [PATCH 3/7] clean up --- spec/ParseQuery.spec.js | 3 --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index f956f5aff4..a9b0e2645f 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -1494,9 +1494,6 @@ describe('Parse.Query testing', () => { success: function(results) { equal(results.length, 2); done(); - }, error: function(error) { - console.log(error); - done(); } }); }); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index b54d3e0d31..097813331f 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -287,8 +287,7 @@ const buildWhereClause = ({ schema, query, index }) => { index += 2; } else if (typeof fieldValue === 'boolean') { patterns.push(`$${index}:name = $${index + 1}`); - - // Can't cast boolean to number + // Can't cast boolean to double precision if (schema.fields[fieldName].type === 'Number') { // Should always return zero const MAX_INT_PLUS_ONE = 9223372036854775808; From 4d032d424862267923f274ebeca032e41f933feb Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 21 Mar 2018 23:57:20 -0500 Subject: [PATCH 4/7] added correct errors --- spec/ParseQuery.spec.js | 12 ++++++++++-- .../Storage/Postgres/PostgresStorageAdapter.js | 10 ++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index a9b0e2645f..c3ce615841 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -844,7 +844,11 @@ describe('Parse.Query testing', () => { const query = new Parse.Query(BoxedNumber); query.containedIn('number', false); return query.find(); - }).then(done.fail).catch(done); + }).then(done.fail).catch((error) => { + equal(error.code, Parse.Error.INVALID_JSON); + equal(error.message, 'bad $in value'); + done(); + }); }); it("notContainedIn false queries", (done) => { @@ -857,7 +861,11 @@ describe('Parse.Query testing', () => { const query = new Parse.Query(BoxedNumber); query.notContainedIn('number', false); return query.find(); - }).then(done.fail).catch(done); + }).then(done.fail).catch((error) => { + equal(error.code, Parse.Error.INVALID_JSON); + equal(error.message, 'bad $nin value'); + done(); + }); }); it("notContainedIn queries", function(done) { diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 097813331f..16a1e57f52 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -400,17 +400,15 @@ const buildWhereClause = ({ schema, query, index }) => { } } if (fieldValue.$in) { - if (!(fieldValue.$in instanceof Array)) { - throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $in value'); - } createConstraint(_.flatMap(fieldValue.$in, elt => elt), false); } if (fieldValue.$nin) { - if (!(fieldValue.$nin instanceof Array)) { - throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $nin value'); - } createConstraint(_.flatMap(fieldValue.$nin, elt => elt), true); } + } else if(fieldValue.$in !== undefined) { + throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $in value'); + } else if (fieldValue.$nin != undefined) { + throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $nin value'); } if (Array.isArray(fieldValue.$all) && isArrayField) { From 94a20b533a12273f8676f1bf0f476d75ce308ec5 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 22 Mar 2018 00:37:40 -0500 Subject: [PATCH 5/7] test fix --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 16a1e57f52..b15e7b439c 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -288,7 +288,7 @@ const buildWhereClause = ({ schema, query, index }) => { } else if (typeof fieldValue === 'boolean') { patterns.push(`$${index}:name = $${index + 1}`); // Can't cast boolean to double precision - if (schema.fields[fieldName].type === 'Number') { + if (schema.fields[fieldName] && schema.fields[fieldName].type === 'Number') { // Should always return zero const MAX_INT_PLUS_ONE = 9223372036854775808; values.push(fieldName, MAX_INT_PLUS_ONE); From 33ca77ead0fd127f10107b70ea44377b01b8518d Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 22 Mar 2018 20:01:00 -0500 Subject: [PATCH 6/7] $eq null test --- spec/ParseQuery.spec.js | 17 +++++++++++++++++ .../Storage/Postgres/PostgresStorageAdapter.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index c3ce615841..bce106b0cb 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -816,6 +816,23 @@ describe('Parse.Query testing', () => { }) }); + it("where $eq null queries (rest)", (done) => { + const options = Object.assign({}, masterKeyOptions, { + body: { + where: { field: { $eq: null } }, + } + }); + const obj1 = new TestObject({ field: false }); + const obj2 = new TestObject({ field: null }); + Parse.Object.saveAll([obj1, obj2]).then(() => { + rp.get(Parse.serverURL + '/classes/TestObject', options) + .then((resp) => { + equal(resp.results.length, 1); + done(); + }); + }) + }); + it("containedIn queries", function(done) { const makeBoxedNumber = function(i) { return new BoxedNumber({ number: i }); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index b15e7b439c..47d9727a56 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -289,7 +289,7 @@ const buildWhereClause = ({ schema, query, index }) => { patterns.push(`$${index}:name = $${index + 1}`); // Can't cast boolean to double precision if (schema.fields[fieldName] && schema.fields[fieldName].type === 'Number') { - // Should always return zero + // Should always return zero results const MAX_INT_PLUS_ONE = 9223372036854775808; values.push(fieldName, MAX_INT_PLUS_ONE); } else { From 897d5bfadd9a164019dfbb507309615fadc330ef Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sat, 24 Mar 2018 15:55:35 -0500 Subject: [PATCH 7/7] type check --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 47d9727a56..ccdfdbd6d6 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -405,9 +405,9 @@ const buildWhereClause = ({ schema, query, index }) => { if (fieldValue.$nin) { createConstraint(_.flatMap(fieldValue.$nin, elt => elt), true); } - } else if(fieldValue.$in !== undefined) { + } else if(typeof fieldValue.$in !== 'undefined') { throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $in value'); - } else if (fieldValue.$nin != undefined) { + } else if (typeof fieldValue.$nin !== 'undefined') { throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $nin value'); }