Finish implementation of delete field from schema

This commit is contained in:
Drew Gross
2016-02-10 14:11:42 -08:00
parent b0c4b8f6ce
commit 0a0d4f65ef
2 changed files with 66 additions and 8 deletions

View File

@@ -520,4 +520,50 @@ describe('Schema', () => {
});
})
});
it('can delete string fields and resave as number field', done => {
var obj1 = hasAllPODobject();
var obj2 = hasAllPODobject();
var p = Parse.Object.saveAll([obj1, obj2])
.then(() => config.database.loadSchema())
.then(schema => schema.deleteField('aString', 'HasAllPOD', config.database.db, 'test_'))
.then(() => new Parse.Query('HasAllPOD').get(obj1.id))
.then(obj1 => {
expect(obj1.get('aString')).toEqual(undefined);
obj1.set('aString', ['not a string', 'this time']);
obj1.save()
.then(obj1 => {
expect(obj1.get('aString')).toEqual(['not a string', 'this time']);
return new Parse.Query('HasAllPOD').get(obj2.id);
})
.then(obj2 => {
expect(obj2.get('aString')).toEqual(undefined);
done();
});
})
});
it('can delete pointer fields and resave as string', done => {
var obj1 = new Parse.Object('NewClass');
obj1.save()
.then(() => {
obj1.set('aPointer', obj1);
return obj1.save();
})
.then(obj1 => {
expect(obj1.get('aPointer').id).toEqual(obj1.id);
})
.then(() => config.database.loadSchema())
.then(schema => schema.deleteField('aPointer', 'NewClass', config.database.db, 'test_'))
.then(() => new Parse.Query('NewClass').get(obj1.id))
.then(obj1 => {
expect(obj1.get('aPointer')).toEqual(undefined);
obj1.set('aPointer', 'Now a string');
return obj1.save();
})
.then(obj1 => {
expect(obj1.get('aPointer')).toEqual('Now a string');
done();
});
});
});