Postgres exclude failing tests (#2081)
* reload the right data More passing postgres tests Handle schema updates, and $in for non array columns remove authdata from user and implement ensureUniqueness Make some tests work, detect existing classes Throw proper error for unique index violation fix findOneAndUpdate Support more types support more type Support boolean, fix _rperm/_wperm, add TODO Support string types and also simplify tests Move operator flattening into Parse Server and out of mongo adapters Move authdata transform for create into Parse Server Move authdata transforms completely in to Parse Server Fix test setup inline addSchema Inject default schema to response from DB adapter * Mark tests that don't work in Postgres * Exclude one more test * Exclude some more failing tests * Exclude more tests
This commit is contained in:
@@ -238,6 +238,7 @@ DatabaseController.prototype.update = function(className, query, update, {
|
||||
}
|
||||
}
|
||||
update = transformObjectACL(update);
|
||||
transformAuthData(className, update, schema);
|
||||
if (many) {
|
||||
return this.adapter.updateObjectsByQuery(className, schema, query, update);
|
||||
} else if (upsert) {
|
||||
@@ -399,6 +400,62 @@ DatabaseController.prototype.destroy = function(className, query, { acl } = {})
|
||||
});
|
||||
};
|
||||
|
||||
const flattenUpdateOperatorsForCreate = object => {
|
||||
for (let key in object) {
|
||||
if (object[key] && object[key].__op) {
|
||||
switch (object[key].__op) {
|
||||
case 'Increment':
|
||||
if (typeof object[key].amount !== 'number') {
|
||||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'objects to add must be an array');
|
||||
}
|
||||
object[key] = object[key].amount;
|
||||
break;
|
||||
case 'Add':
|
||||
if (!(object[key].objects instanceof Array)) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'objects to add must be an array');
|
||||
}
|
||||
object[key] = object[key].objects;
|
||||
break;
|
||||
case 'AddUnique':
|
||||
if (!(object[key].objects instanceof Array)) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'objects to add must be an array');
|
||||
}
|
||||
object[key] = object[key].objects;
|
||||
break;
|
||||
case 'Remove':
|
||||
if (!(object[key].objects instanceof Array)) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'objects to add must be an array');
|
||||
}
|
||||
object[key] = []
|
||||
break;
|
||||
case 'Delete':
|
||||
delete object[key];
|
||||
break;
|
||||
default:
|
||||
throw new Parse.Error(Parse.Error.COMMAND_UNAVAILABLE, `The ${object[key].__op} operator is not supported yet.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const transformAuthData = (className, object, schema) => {
|
||||
if (object.authData && className === '_User') {
|
||||
Object.keys(object.authData).forEach(provider => {
|
||||
const providerData = object.authData[provider];
|
||||
const fieldName = `_auth_data_${provider}`;
|
||||
if (providerData == null) {
|
||||
object[fieldName] = {
|
||||
__op: 'Delete'
|
||||
}
|
||||
} else {
|
||||
object[fieldName] = providerData;
|
||||
schema.fields[fieldName] = { type: 'Object' }
|
||||
}
|
||||
});
|
||||
delete object.authData;
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts an object into the database.
|
||||
// Returns a promise that resolves successfully iff the object saved.
|
||||
DatabaseController.prototype.create = function(className, object, { acl } = {}) {
|
||||
@@ -420,7 +477,11 @@ DatabaseController.prototype.create = function(className, object, { acl } = {})
|
||||
.then(() => schemaController.enforceClassExists(className))
|
||||
.then(() => schemaController.reloadData())
|
||||
.then(() => schemaController.getOneSchema(className, true))
|
||||
.then(schema => this.adapter.createObject(className, SchemaController.convertSchemaToAdapterSchema(schema), object))
|
||||
.then(schema => {
|
||||
transformAuthData(className, object, schema);
|
||||
flattenUpdateOperatorsForCreate(object);
|
||||
return this.adapter.createObject(className, SchemaController.convertSchemaToAdapterSchema(schema), object);
|
||||
})
|
||||
.then(result => sanitizeDatabaseResult(originalObject, result.ops[0]));
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user