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
This commit is contained in:
committed by
Florent Vilmart
parent
0add7c0c50
commit
52828683ba
@@ -26,6 +26,29 @@ describe('Parse.GeoPoint testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has the correct __type field in the json response', done => {
|
||||||
|
var point = new Parse.GeoPoint(44.0, -11.0);
|
||||||
|
var obj = new TestObject();
|
||||||
|
obj.set('location', point);
|
||||||
|
obj.set('name', 'Zhoul')
|
||||||
|
obj.save(null, {
|
||||||
|
success: (obj) => {
|
||||||
|
console.log(obj);
|
||||||
|
Parse.Cloud.httpRequest({
|
||||||
|
url: 'http://localhost:8378/1/classes/TestObject/' + obj.id,
|
||||||
|
headers: {
|
||||||
|
'X-Parse-Application-Id': 'test',
|
||||||
|
'X-Parse-Master-Key': 'test'
|
||||||
|
}
|
||||||
|
}).then(response => {
|
||||||
|
equal(response.data.location.__type, 'GeoPoint');
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('geo point exception two fields', (done) => {
|
it('geo point exception two fields', (done) => {
|
||||||
var point = new Parse.GeoPoint(20, 20);
|
var point = new Parse.GeoPoint(20, 20);
|
||||||
var obj = new TestObject();
|
var obj = new TestObject();
|
||||||
|
|||||||
@@ -1074,6 +1074,7 @@ export class PostgresStorageAdapter {
|
|||||||
}
|
}
|
||||||
if (object[fieldName] && schema.fields[fieldName].type === 'GeoPoint') {
|
if (object[fieldName] && schema.fields[fieldName].type === 'GeoPoint') {
|
||||||
object[fieldName] = {
|
object[fieldName] = {
|
||||||
|
__type: "GeoPoint",
|
||||||
latitude: object[fieldName].y,
|
latitude: object[fieldName].y,
|
||||||
longitude: object[fieldName].x
|
longitude: object[fieldName].x
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user