From 3a1c378a2c7073a54cc9a9cff5b954cc3b63bd50 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 28 May 2017 11:02:39 -0500 Subject: [PATCH] Fix Geopoint issue #3285 --- spec/ParseGeoPoint.spec.js | 19 +++++++++++++++++++ .../Postgres/PostgresStorageAdapter.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/ParseGeoPoint.spec.js b/spec/ParseGeoPoint.spec.js index 1dd7710ede..71b1b0ef5a 100644 --- a/spec/ParseGeoPoint.spec.js +++ b/spec/ParseGeoPoint.spec.js @@ -26,6 +26,25 @@ describe('Parse.GeoPoint testing', () => { }); }); + it('update geopoint', (done) => { + const oldPoint = new Parse.GeoPoint(44.0, -11.0); + const newPoint = new Parse.GeoPoint(24.0, 19.0); + const obj = new TestObject(); + obj.set('location', oldPoint); + obj.save().then(() => { + obj.set('location', newPoint); + return obj.save(); + }).then(() => { + var query = new Parse.Query(TestObject); + return query.get(obj.id); + }).then((result) => { + const point = result.get('location'); + equal(point.latitude, newPoint.latitude); + equal(point.longitude, newPoint.longitude); + done(); + }); + }); + it('has the correct __type field in the json response', done => { var point = new Parse.GeoPoint(44.0, -11.0); var obj = new TestObject(); diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 5beba28c65..8936d29542 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -920,7 +920,7 @@ export class PostgresStorageAdapter { index += 2; } else if (fieldValue.__type === 'GeoPoint') { updatePatterns.push(`$${index}:name = POINT($${index + 1}, $${index + 2})`); - values.push(fieldName, fieldValue.latitude, fieldValue.longitude); + values.push(fieldName, fieldValue.longitude, fieldValue.latitude); index += 3; } else if (fieldValue.__type === 'Relation') { // noop