Skip to content

Commit 1cffbd5

Browse files
authored
improvement: identify primary keys as such (#504)
1 parent 4bd017a commit 1cffbd5

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/services/apimap-field-builder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ function ApimapFieldBuilder(model, column, options) {
144144
};
145145

146146
if (column.primaryKey === true) {
147-
schema.primaryKey = true;
147+
schema.isPrimaryKey = true;
148148
}
149+
149150
if (schema.type === 'Enum') {
150151
schema.enums = column.values;
151152
}

test/adapters/sequelize.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function getField(schema, name) {
6363
field: 'id',
6464
type: 'Number',
6565
columnName: 'id',
66-
primaryKey: true,
66+
isPrimaryKey: true,
6767
});
6868
});
6969

test/services/apimap-field-builder.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ describe('services > apimap-field-builder', () => {
6767
},
6868
};
6969

70+
it('should be set as primary key', async () => {
71+
expect.assertions(1);
72+
const { uuid } = await initializeField(fieldDefinitions);
73+
expect(uuid.isPrimaryKey).toStrictEqual(true);
74+
});
75+
7076
it('should be set as required', async () => {
7177
expect.assertions(1);
7278
const { uuid } = await initializeField(fieldDefinitions);

0 commit comments

Comments
 (0)