Refactor MongoTransform.js (#1823)
* Split transformAtom into transfromTopLevelAtom and transformInteriorAtom * Use single param for inArray and inObject * Tidyness in transformKeyValue * Add transformInteriorKeyValue * Remove update from tranformInteriorKeyValue * Split out transform update * Move validation out of transfromUpdate * Remove force paramater from transformTopLevelAtom throw error after if necessary * Turn transformKeyValue into transfromKey since it is only used for that purpose * Remove unnecessary stuff from transformKey * convert transformKey to use parse format schema * interior keys fixes * Add test for interior keys with special names * Correct validation of inner keys
This commit is contained in:
@@ -1437,4 +1437,36 @@ describe('miscellaneous', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('doesnt convert interior keys of objects that use special names', done => {
|
||||
let obj = new Parse.Object('Obj');
|
||||
obj.set('val', { createdAt: 'a', updatedAt: 1 });
|
||||
obj.save()
|
||||
.then(obj => new Parse.Query('Obj').get(obj.id))
|
||||
.then(obj => {
|
||||
expect(obj.get('val').createdAt).toEqual('a');
|
||||
expect(obj.get('val').updatedAt).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('bans interior keys containing . or $', done => {
|
||||
new Parse.Object('Obj').save({innerObj: {'key with a $': 'fails'}})
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(Parse.Error.INVALID_NESTED_KEY);
|
||||
return new Parse.Object('Obj').save({innerObj: {'key with a .': 'fails'}});
|
||||
})
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(Parse.Error.INVALID_NESTED_KEY);
|
||||
return new Parse.Object('Obj').save({innerObj: {innerInnerObj: {'key with $': 'fails'}}});
|
||||
})
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(Parse.Error.INVALID_NESTED_KEY);
|
||||
return new Parse.Object('Obj').save({innerObj: {innerInnerObj: {'key with .': 'fails'}}});
|
||||
})
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(Parse.Error.INVALID_NESTED_KEY);
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user