fix: create collection with emtpy inhertis params (#1096)

This commit is contained in:
ChengLei Shao 2022-11-16 22:07:52 +08:00 committed by GitHub
parent c5fcc62bed
commit 49f6c18662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View File

@ -15,6 +15,20 @@ pgOnly()('collection inherits', () => {
await db.close();
});
it('should pass empty inherits params', async () => {
const table1 = db.collection({
name: 'table1',
fields: [{ type: 'string', name: 'name' }],
});
const table2 = db.collection({
name: 'table2',
inherits: [],
});
expect(table2).not.toBeInstanceOf(InheritedCollection);
});
it('should remove Node after collection destroy', async () => {
const table1 = db.collection({
name: 'table1',

View File

@ -302,7 +302,8 @@ export class Database extends EventEmitter implements AsyncEmitter {
): Collection<Attributes, CreateAttributes> {
this.emit('beforeDefineCollection', options);
const collection = options.inherits
const collection =
options.inherits && lodash.castArray(options.inherits).length > 0
? new InheritedCollection(options, {
database: this,
})

@ -1 +1 @@
Subproject commit 1b8a029238b9dfcf70e7f8b3cbd52e9f180f67f2
Subproject commit 5a5fba41ae1cecaf3b073fcb610e9dc68dad0b85