diff --git a/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts b/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts index 0f94899878..35224fe062 100644 --- a/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts +++ b/packages/core/database/src/__tests__/inhertits/collection-inherits.test.ts @@ -15,6 +15,35 @@ pgOnly()('collection inherits', () => { await db.close(); }); + it('should inherit from no id table', async () => { + const interfaceCollection = db.collection({ + name: 'a', + fields: [ + { + type: 'string', + name: 'name', + }, + ], + timestamps: false, + }); + + interfaceCollection.model.removeAttribute('id'); + const child = db.collection({ + name: 'b', + inherits: ['a'], + }); + + await db.sync(); + + const childInstance = await child.repository.create({ + values: { + name: 'test', + }, + }); + + expect(childInstance.get('name')).toBe('test'); + }); + it('should pass empty inherits params', async () => { const table1 = db.collection({ name: 'table1', diff --git a/packages/core/database/src/sync-runner.ts b/packages/core/database/src/sync-runner.ts index a1507e11df..a5c6acc47d 100644 --- a/packages/core/database/src/sync-runner.ts +++ b/packages/core/database/src/sync-runner.ts @@ -40,6 +40,11 @@ export class SyncRunner { transaction, }, ); + + if (!sequenceNameResult[0].length) { + continue; + } + const columnDefault = sequenceNameResult[0][0]['column_default']; if (!columnDefault) {