Skip to content

Commit

Permalink
Enable API related tests for Postgres (#2970)
Browse files Browse the repository at this point in the history
  • Loading branch information
kulshekhar authored and flovilmart committed Oct 31, 2016
1 parent edf6ab6 commit 78646a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ it('ensure that if you try to sign up a user with a unique username and email, b
});
});

it_exclude_dbs(['postgres'])('bans interior keys containing . or $', done => {
it('bans interior keys containing . or $', done => {
new Parse.Object('Obj').save({innerObj: {'key with a $': 'fails'}})
.then(() => {
fail('should not succeed')
Expand Down
16 changes: 16 additions & 0 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ const handleDotFields = (object) => {
return object;
}

const validateKeys = (object) => {
if (typeof object == 'object') {
for (const key in object) {
if (typeof object[key] == 'object') {
validateKeys(object[key]);
}

if(key.includes('$') || key.includes('.')){
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
}
}
}
}

// Returns the list of join tables on a schema
const joinTablesForSchema = (schema) => {
let list = [];
Expand Down Expand Up @@ -649,6 +663,8 @@ export class PostgresStorageAdapter {

object = handleDotFields(object);

validateKeys(object);

Object.keys(object).forEach(fieldName => {
var authDataMatch = fieldName.match(/^_auth_data_([a-zA-Z0-9_]+)$/);
if (authDataMatch) {
Expand Down

0 comments on commit 78646a3

Please sign in to comment.