This commit is contained in:
Drew
2016-05-26 16:15:54 -07:00
committed by Florent Vilmart
parent c5e3be8b64
commit 50b9ae4803
2 changed files with 18 additions and 1 deletions

View File

@@ -1556,4 +1556,21 @@ describe('schemas', () => {
done();
})
})
it('gives correct response when deleting a schema with CLPs (regression test #1919)', done => {
new Parse.Object('MyClass').save({ data: 'foo'})
.then(obj => obj.destroy())
.then(() => setPermissionsOnClass('MyClass', { find: {}, get: {} }, true))
.then(() => {
request.del({
url: 'http://localhost:8378/1/schemas/MyClass',
headers: masterKeyHeaders,
json: true,
}, (error, response, body) => {
expect(response.statusCode).toEqual(200);
expect(response.body).toEqual({});
done();
});
});
});
});

View File

@@ -67,7 +67,7 @@ function modifySchema(req) {
// A helper function that removes all join tables for a schema. Returns a promise.
var removeJoinTables = (database, mongoSchema) => {
return Promise.all(Object.keys(mongoSchema)
.filter(field => mongoSchema[field].startsWith('relation<'))
.filter(field => field !== '_metadata' && mongoSchema[field].startsWith('relation<'))
.map(field => {
let collectionName = `_Join:${field}:${mongoSchema._id}`;
return database.adapter.deleteOneSchema(collectionName);