From 23326d8517cb19f8265886395f3bdab2cac7745d Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 20 Jun 2016 16:47:45 -0400 Subject: [PATCH 1/4] Add null check for relation type map. For relations that are not explicitly defined in the schema, we need a null check here. --- src/Controllers/DatabaseController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index 811f9b0a3e..6ba00625c8 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -121,7 +121,7 @@ DatabaseController.prototype.loadSchema = function() { DatabaseController.prototype.redirectClassNameForKey = function(className, key) { return this.loadSchema().then((schema) => { var t = schema.getExpectedType(className, key); - if (t.type == 'Relation') { + if (t && t.type == 'Relation') { return t.targetClass; } else { return className; From 9edea1e7625762b457472e4384dc133e5e499401 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 21 Jun 2016 14:27:22 -0400 Subject: [PATCH 2/4] Making change to force rebuild. --- src/Controllers/DatabaseController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index 6ba00625c8..48e72806dd 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -1,4 +1,4 @@ -// A database adapter that works with data exported from the hosted +// A database adapter that works with data exported from the hosted // Parse database. import intersect from 'intersect'; @@ -121,7 +121,7 @@ DatabaseController.prototype.loadSchema = function() { DatabaseController.prototype.redirectClassNameForKey = function(className, key) { return this.loadSchema().then((schema) => { var t = schema.getExpectedType(className, key); - if (t && t.type == 'Relation') { + if (t && t.type == 'Relation') { return t.targetClass; } else { return className; From fe0188fcf29747a0ac7401a870b2257470d640b5 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 21 Jun 2016 14:27:36 -0400 Subject: [PATCH 3/4] Reverting change. --- src/Controllers/DatabaseController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index 48e72806dd..09891a3c98 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -121,7 +121,7 @@ DatabaseController.prototype.loadSchema = function() { DatabaseController.prototype.redirectClassNameForKey = function(className, key) { return this.loadSchema().then((schema) => { var t = schema.getExpectedType(className, key); - if (t && t.type == 'Relation') { + if (t && t.type == 'Relation') { return t.targetClass; } else { return className; From 60ad4e05606267814870e24d69e774397a472c5c Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Mon, 18 Jul 2016 19:55:24 -0400 Subject: [PATCH 4/4] Adds test --- spec/ParseUser.spec.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index d2daa46e1a..24382cc1e0 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -2595,5 +2595,22 @@ describe('Parse.User testing', () => { }) }); }); - }) + }); + + it_exclude_dbs(['postgres'])('should not fail querying non existing relations', done => { + let user = new Parse.User(); + user.set({ + username: 'hello', + password: 'world' + }) + user.signUp().then(() => { + return Parse.User.current().relation('relation').query().find(); + }).then((res) => { + expect(res.length).toBe(0); + done(); + }).catch((err) => { + fail(JSON.stringify(err)); + done(); + }); + }); });