Skip to content

Commit 193e5a4

Browse files
flovilmartnatanrolnik
authored andcommitted
Make sure we don't treat dot notation keys as topLevel atoms (#3531)
Fixing GeoPoints and Files in _GlobalConfig
1 parent 6ae0675 commit 193e5a4

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

spec/ParseGlobalConfig.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,49 @@ describe('a GlobalConfig', () => {
5656
});
5757
});
5858

59+
it('can add and retrive files', (done) => {
60+
request.put({
61+
url : 'http://localhost:8378/1/config',
62+
json : true,
63+
body : { params: { file: { __type: 'File', name: 'name', url: 'http://url' } } },
64+
headers: {
65+
'X-Parse-Application-Id': 'test',
66+
'X-Parse-Master-Key' : 'test'
67+
}
68+
}, (error, response, body) => {
69+
expect(response.statusCode).toEqual(200);
70+
expect(body.result).toEqual(true);
71+
Parse.Config.get().then((res) => {
72+
const file = res.get('file');
73+
expect(file.name()).toBe('name');
74+
expect(file.url()).toBe('http://url');
75+
done();
76+
});
77+
});
78+
});
79+
80+
it('can add and retrive Geopoints', (done) => {
81+
const geopoint = new Parse.GeoPoint(10,-20);
82+
request.put({
83+
url : 'http://localhost:8378/1/config',
84+
json : true,
85+
body : { params: { point: geopoint.toJSON() } },
86+
headers: {
87+
'X-Parse-Application-Id': 'test',
88+
'X-Parse-Master-Key' : 'test'
89+
}
90+
}, (error, response, body) => {
91+
expect(response.statusCode).toEqual(200);
92+
expect(body.result).toEqual(true);
93+
Parse.Config.get().then((res) => {
94+
const point = res.get('point');
95+
expect(point.latitude).toBe(10);
96+
expect(point.longitude).toBe(-20);
97+
done();
98+
});
99+
});
100+
});
101+
59102
it('properly handles delete op', (done) => {
60103
request.put({
61104
url : 'http://localhost:8378/1/config',

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ const transformKeyValueForUpdate = (className, restKey, restValue, parseFormatSc
8989
if (timeField && (typeof value === 'string')) {
9090
value = new Date(value);
9191
}
92+
if (restKey.indexOf('.') > 0) {
93+
return {key, value: restValue}
94+
}
9295
return {key, value};
9396
}
9497

@@ -98,7 +101,7 @@ const transformKeyValueForUpdate = (className, restKey, restValue, parseFormatSc
98101
return {key, value};
99102
}
100103

101-
// Handle update operators
104+
// Handle update operators
102105
if (typeof restValue === 'object' && '__op' in restValue) {
103106
return {key, value: transformUpdateOperator(restValue, false)};
104107
}

0 commit comments

Comments
 (0)