Skip to content

Commit 78646a3

Browse files
kulshekharflovilmart
authored andcommitted
Enable API related tests for Postgres (#2970)
1 parent edf6ab6 commit 78646a3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

spec/ParseAPI.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ it('ensure that if you try to sign up a user with a unique username and email, b
13061306
});
13071307
});
13081308

1309-
it_exclude_dbs(['postgres'])('bans interior keys containing . or $', done => {
1309+
it('bans interior keys containing . or $', done => {
13101310
new Parse.Object('Obj').save({innerObj: {'key with a $': 'fails'}})
13111311
.then(() => {
13121312
fail('should not succeed')

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+16
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ const handleDotFields = (object) => {
136136
return object;
137137
}
138138

139+
const validateKeys = (object) => {
140+
if (typeof object == 'object') {
141+
for (const key in object) {
142+
if (typeof object[key] == 'object') {
143+
validateKeys(object[key]);
144+
}
145+
146+
if(key.includes('$') || key.includes('.')){
147+
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
148+
}
149+
}
150+
}
151+
}
152+
139153
// Returns the list of join tables on a schema
140154
const joinTablesForSchema = (schema) => {
141155
let list = [];
@@ -649,6 +663,8 @@ export class PostgresStorageAdapter {
649663

650664
object = handleDotFields(object);
651665

666+
validateKeys(object);
667+
652668
Object.keys(object).forEach(fieldName => {
653669
var authDataMatch = fieldName.match(/^_auth_data_([a-zA-Z0-9_]+)$/);
654670
if (authDataMatch) {

0 commit comments

Comments
 (0)