fix: create collection with emtpy inhertis params (#1096)
This commit is contained in:
parent
c5fcc62bed
commit
49f6c18662
@ -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',
|
||||
|
@ -302,13 +302,14 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
||||
): Collection<Attributes, CreateAttributes> {
|
||||
this.emit('beforeDefineCollection', options);
|
||||
|
||||
const collection = options.inherits
|
||||
? new InheritedCollection(options, {
|
||||
database: this,
|
||||
})
|
||||
: new Collection(options, {
|
||||
database: this,
|
||||
});
|
||||
const collection =
|
||||
options.inherits && lodash.castArray(options.inherits).length > 0
|
||||
? new InheritedCollection(options, {
|
||||
database: this,
|
||||
})
|
||||
: new Collection(options, {
|
||||
database: this,
|
||||
});
|
||||
|
||||
this.collections.set(collection.name, collection);
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1b8a029238b9dfcf70e7f8b3cbd52e9f180f67f2
|
||||
Subproject commit 5a5fba41ae1cecaf3b073fcb610e9dc68dad0b85
|
Loading…
Reference in New Issue
Block a user