Allow creation of indices on default fields (#4738)

* Allow creation of indexes on default fields

* Update test

* Try to address flaky cache test
This commit is contained in:
Claire Neveu
2018-04-25 19:06:10 -04:00
committed by Tyler Brock
parent b1017ac17c
commit 04588bccb9
3 changed files with 27 additions and 2 deletions

View File

@@ -530,6 +530,8 @@ export default class SchemaController {
delete existingFields._rperm;
delete existingFields._wperm;
const newSchema = buildMergedSchemaObject(existingFields, submittedFields);
const defaultFields = defaultColumns[className] || defaultColumns._Default;
const fullNewSchema = Object.assign({}, newSchema, defaultFields);
const validationError = this.validateSchemaData(className, newSchema, classLevelPermissions, Object.keys(existingFields));
if (validationError) {
throw new Parse.Error(validationError.code, validationError.error);
@@ -561,7 +563,7 @@ export default class SchemaController {
return Promise.all(promises);
})
.then(() => this.setPermissions(className, classLevelPermissions, newSchema))
.then(() => this._dbAdapter.setIndexesWithSchemaFormat(className, indexes, schema.indexes, newSchema))
.then(() => this._dbAdapter.setIndexesWithSchemaFormat(className, indexes, schema.indexes, fullNewSchema))
.then(() => this.reloadData({ clearCache: true }))
//TODO: Move this logic into the database adapter
.then(() => {