Skip to content

Commit 5282868

Browse files
dan-drflovilmart
authored andcommitted
Add __type property to GeoPoint fields in PostgresStorageAdapter (#3695)
* Add __type property to GeoPoint fields in PostgresStorageAdapter * Add test to check __type on GeoPoint queries
1 parent 0add7c0 commit 5282868

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

spec/ParseGeoPoint.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ describe('Parse.GeoPoint testing', () => {
2626
});
2727
});
2828

29+
it('has the correct __type field in the json response', done => {
30+
var point = new Parse.GeoPoint(44.0, -11.0);
31+
var obj = new TestObject();
32+
obj.set('location', point);
33+
obj.set('name', 'Zhoul')
34+
obj.save(null, {
35+
success: (obj) => {
36+
console.log(obj);
37+
Parse.Cloud.httpRequest({
38+
url: 'http://localhost:8378/1/classes/TestObject/' + obj.id,
39+
headers: {
40+
'X-Parse-Application-Id': 'test',
41+
'X-Parse-Master-Key': 'test'
42+
}
43+
}).then(response => {
44+
equal(response.data.location.__type, 'GeoPoint');
45+
done();
46+
})
47+
}
48+
})
49+
});
50+
51+
2952
it('geo point exception two fields', (done) => {
3053
var point = new Parse.GeoPoint(20, 20);
3154
var obj = new TestObject();

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ export class PostgresStorageAdapter {
10741074
}
10751075
if (object[fieldName] && schema.fields[fieldName].type === 'GeoPoint') {
10761076
object[fieldName] = {
1077+
__type: "GeoPoint",
10771078
latitude: object[fieldName].y,
10781079
longitude: object[fieldName].x
10791080
}

0 commit comments

Comments
 (0)