fix: create inherits from a table that has no id (#1104)

* fix: create inherits from no id table

* chore: console.log
This commit is contained in:
ChengLei Shao 2022-11-18 20:46:55 +08:00 committed by GitHub
parent 395c441b21
commit 8cad307fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -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',

View File

@ -40,6 +40,11 @@ export class SyncRunner {
transaction,
},
);
if (!sequenceNameResult[0].length) {
continue;
}
const columnDefault = sequenceNameResult[0][0]['column_default'];
if (!columnDefault) {