From e9053dbd9f393e7152d53c6c844bad503ecfb1a5 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 20 Jul 2017 00:17:12 -0500 Subject: [PATCH] pg support for null in containedAll --- spec/ParseQuery.spec.js | 15 +++++++++++++++ .../Storage/Postgres/PostgresStorageAdapter.js | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index 8eee6098e8..b7b6621e76 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -274,6 +274,21 @@ describe('Parse.Query testing', () => { }); }); + it('containedIn null array', (done) => { + const emails = ['contact@xyz.com', 'contact@zyx.com', null]; + const user = new Parse.User(); + user.setUsername(emails[0]); + user.setPassword('asdf'); + user.signUp().then(() => { + const query = new Parse.Query(Parse.User); + query.containedIn('username', emails); + return query.find({ useMasterKey: true }); + }).then((results) => { + equal(results.length, 1); + done(); + }, done.fail); + }); + it("containsAll number array queries", function(done) { var NumberSet = Parse.Object.extend({ className: "NumberSet" }); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 07801bd661..6cdac7ad79 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -301,8 +301,10 @@ const buildWhereClause = ({ schema, query, index }) => { const inPatterns = []; values.push(fieldName); baseArray.forEach((listElem, listIndex) => { - values.push(listElem); - inPatterns.push(`$${index + 1 + listIndex}`); + if (listElem !== null) { + values.push(listElem); + inPatterns.push(`$${index + 1 + listIndex}`); + } }); patterns.push(`$${index}:name ${not} IN (${inPatterns.join(',')})`); index = index + 1 + inPatterns.length;