diff --git a/package.json b/package.json index 79f596fcf0..dd4dae4169 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "mime": "1.4.0", "mongodb": "2.2.31", "multer": "1.3.0", - "parse": "1.10.0", + "parse": "1.10.1", "parse-server-fs-adapter": "1.0.1", "parse-server-push-adapter": "2.0.0", "parse-server-s3-adapter": "1.2.0", diff --git a/spec/ParsePolygon.spec.js b/spec/ParsePolygon.spec.js index 44dd66fd90..f4ca455ae7 100644 --- a/spec/ParsePolygon.spec.js +++ b/spec/ParsePolygon.spec.js @@ -12,13 +12,13 @@ describe('Parse.Polygon testing', () => { const coords = [[0,0],[0,1],[1,1],[1,0]]; const closed = [[0,0],[0,1],[1,1],[1,0],[0,0]]; const obj = new TestObject(); - obj.set('polygon', {__type: 'Polygon', coordinates: coords}); + obj.set('polygon', new Parse.Polygon(coords)); return obj.save().then(() => { const query = new Parse.Query(TestObject); return query.get(obj.id); }).then((result) => { const polygon = result.get('polygon'); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, closed); done(); }, done.fail); @@ -27,13 +27,13 @@ describe('Parse.Polygon testing', () => { it('polygon save closed path', (done) => { const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]]; const obj = new TestObject(); - obj.set('polygon', {__type: 'Polygon', coordinates: coords}); + obj.set('polygon', new Parse.Polygon(coords)); return obj.save().then(() => { const query = new Parse.Query(TestObject); return query.get(obj.id); }).then((result) => { const polygon = result.get('polygon'); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, coords); done(); }, done.fail); @@ -42,8 +42,8 @@ describe('Parse.Polygon testing', () => { it('polygon equalTo (open/closed) path', (done) => { const openPoints = [[0,0],[0,1],[1,1],[1,0]]; const closedPoints = [[0,0],[0,1],[1,1],[1,0],[0,0]]; - const openPolygon = {__type: 'Polygon', coordinates: openPoints}; - const closedPolygon = {__type: 'Polygon', coordinates: closedPoints}; + const openPolygon = new Parse.Polygon(openPoints); + const closedPolygon = new Parse.Polygon(closedPoints); const obj = new TestObject(); obj.set('polygon', openPolygon); return obj.save().then(() => { @@ -52,14 +52,14 @@ describe('Parse.Polygon testing', () => { return query.find(); }).then((results) => { const polygon = results[0].get('polygon'); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, closedPoints); const query = new Parse.Query(TestObject); query.equalTo('polygon', closedPolygon); return query.find(); }).then((results) => { const polygon = results[0].get('polygon'); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, closedPoints); done(); }, done.fail); @@ -67,9 +67,9 @@ describe('Parse.Polygon testing', () => { it('polygon update', (done) => { const oldCoords = [[0,0],[0,1],[1,1],[1,0]]; - const oldPolygon = {__type: 'Polygon', coordinates: oldCoords}; + const oldPolygon = new Parse.Polygon(oldCoords); const newCoords = [[2,2],[2,3],[3,3],[3,2]]; - const newPolygon = {__type: 'Polygon', coordinates: newCoords}; + const newPolygon = new Parse.Polygon(newCoords); const obj = new TestObject(); obj.set('polygon', oldPolygon); return obj.save().then(() => { @@ -81,7 +81,7 @@ describe('Parse.Polygon testing', () => { }).then((result) => { const polygon = result.get('polygon'); newCoords.push(newCoords[0]); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, newCoords); done(); }, done.fail); @@ -100,6 +100,7 @@ describe('Parse.Polygon testing', () => { it('polygon three points minimum', (done) => { const coords = [[0,0]]; const obj = new TestObject(); + // use raw so we test the server validates properly obj.set('polygon', {__type: 'Polygon', coordinates: coords}); obj.save().then(done.fail, done); }); @@ -107,7 +108,7 @@ describe('Parse.Polygon testing', () => { it('polygon three different points minimum', (done) => { const coords = [[0,0],[0,1],[0,0]]; const obj = new TestObject(); - obj.set('polygon', {__type: 'Polygon', coordinates: coords}); + obj.set('polygon', new Parse.Polygon(coords)); obj.save().then(done.fail, done); }); @@ -115,13 +116,13 @@ describe('Parse.Polygon testing', () => { const coords = [[1,1],[0,1],[0,0],[1,0]]; const closed = [[1,1],[0,1],[0,0],[1,0],[1,1]]; const obj = new TestObject(); - obj.set('polygon', {__type: 'Polygon', coordinates: coords}); + obj.set('polygon', new Parse.Polygon(coords)); obj.save().then(() => { const query = new Parse.Query(TestObject); return query.get(obj.id); }).then((result) => { const polygon = result.get('polygon'); - equal(polygon.__type, 'Polygon'); + equal(polygon instanceof Parse.Polygon, true); equal(polygon.coordinates, closed); done(); }, done.fail); @@ -131,9 +132,9 @@ describe('Parse.Polygon testing', () => { const points1 = [[0,0],[0,1],[1,1],[1,0]]; const points2 = [[0,0],[0,2],[2,2],[2,0]]; const points3 = [[10,10],[10,15],[15,15],[15,10],[10,10]]; - const polygon1 = {__type: 'Polygon', coordinates: points1}; - const polygon2 = {__type: 'Polygon', coordinates: points2}; - const polygon3 = {__type: 'Polygon', coordinates: points3}; + const polygon1 = new Parse.Polygon(points1); + const polygon2 = new Parse.Polygon(points2); + const polygon3 = new Parse.Polygon(points3); const obj1 = new TestObject({location: polygon1}); const obj2 = new TestObject({location: polygon2}); const obj3 = new TestObject({location: polygon3}); @@ -161,7 +162,7 @@ describe('Parse.Polygon testing', () => { it('polygonContain invalid input', (done) => { const points = [[0,0],[0,1],[1,1],[1,0]]; - const polygon = {__type: 'Polygon', coordinates: points}; + const polygon = new Parse.Polygon(points); const obj = new TestObject({location: polygon}); obj.save().then(() => { const where = { @@ -184,7 +185,7 @@ describe('Parse.Polygon testing', () => { it('polygonContain invalid geoPoint', (done) => { const points = [[0,0],[0,1],[1,1],[1,0]]; - const polygon = {__type: 'Polygon', coordinates: points}; + const polygon = new Parse.Polygon(points); const obj = new TestObject({location: polygon}); obj.save().then(() => { const where = { @@ -209,6 +210,7 @@ describe('Parse.Polygon testing', () => { describe_only_db('mongo')('Parse.Polygon testing', () => { it('support 2d and 2dsphere', (done) => { const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]]; + // testings against REST API, use raw formats const polygon = {__type: 'Polygon', coordinates: coords}; const location = {__type: 'GeoPoint', latitude:10, longitude:10}; const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI }); @@ -256,7 +258,7 @@ describe_only_db('mongo')('Parse.Polygon testing', () => { it('polygon loop is not valid', (done) => { const coords = [[0,0],[0,1],[1,0],[1,1]]; const obj = new TestObject(); - obj.set('polygon', {__type: 'Polygon', coordinates: coords}); + obj.set('polygon', new Parse.Polygon(coords)); obj.save().then(done.fail, done); }); }); diff --git a/spec/ParseQuery.spec.js b/spec/ParseQuery.spec.js index 9781d45a89..eb82afab60 100644 --- a/spec/ParseQuery.spec.js +++ b/spec/ParseQuery.spec.js @@ -3086,4 +3086,26 @@ describe('Parse.Query testing', () => { done(); }, done.fail); }); + + it('should not interfere with has when using select on field with undefined value #3999', (done) => { + const obj1 = new Parse.Object('TestObject'); + const obj2 = new Parse.Object('OtherObject'); + obj2.set('otherField', 1); + obj1.set('testPointerField', obj2); + obj1.set('shouldBe', true); + const obj3 = new Parse.Object('TestObject'); + obj3.set('shouldBe', false); + Parse.Object.saveAll([obj1, obj3]).then(() => { + const query = new Parse.Query('TestObject'); + query.include('testPointerField'); + query.select(['testPointerField', 'testPointerField.otherField', 'shouldBe']); + return query.find(); + }).then(results => { + results.forEach(result => { + equal(result.has('testPointerField'), result.get('shouldBe')); + }); + done(); + } + ).catch(done.fail); + }); });