Skip to content

Commit 92463c0

Browse files
authored
feat(filter): handle correctly uuid field type (#835)
1 parent 5f8721d commit 92463c0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/services/apimap-field-type-detector.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ function ApimapFieldTypeDetector(column, options) {
44
this.perform = () => {
55
if (column.type instanceof DataTypes.STRING
66
|| column.type instanceof DataTypes.TEXT
7-
|| column.type instanceof DataTypes.UUID
8-
|| column.type instanceof DataTypes.UUIDV1
9-
|| column.type instanceof DataTypes.UUIDV4
107
|| (DataTypes.CITEXT && column.type instanceof DataTypes.CITEXT)
118
|| column.type === 'citext') { // TODO: Remove 'citext' once Sequelize 4 has been deprecated.
129
return 'String';
@@ -41,6 +38,11 @@ function ApimapFieldTypeDetector(column, options) {
4138
&& column.type.type === 'POINT') {
4239
return 'Point';
4340
}
41+
if (column.type instanceof DataTypes.UUID
42+
|| column.type instanceof DataTypes.UUIDV1
43+
|| column.type instanceof DataTypes.UUIDV4) {
44+
return 'Uuid';
45+
}
4446
// NOTICE: Detect Array types (Array(String), Array(Integer), ...)
4547
if (column.type.type) {
4648
return [new ApimapFieldTypeDetector({ type: column.type.type }, options).perform()];

test/databases.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ const user = { renderingId: 1 };
483483
expect(schema.fields[7].type).toStrictEqual('Date');
484484
expect(schema.fields[8].type).toStrictEqual('Date');
485485
expect(schema.fields[9].type).toStrictEqual('String');
486-
expect(schema.fields[10].type).toStrictEqual('String');
486+
expect(schema.fields[10].type).toStrictEqual('Uuid');
487487
expect(schema.fields[11].type).toStrictEqual('Number');
488488
expect(schema.fields[12].type[0]).toStrictEqual('Number');
489489
expect(schema.fields[13].type[0]).toStrictEqual('Number');

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ describe('services > apimap-field-builder', () => {
3838
expect(uuid.field).toStrictEqual('uuid');
3939
});
4040

41-
it('should have a String type', () => {
41+
it('should have a Uuid type', () => {
4242
expect.assertions(1);
4343
const { uuid } = initializeField(fieldDefinitions);
44-
expect(uuid.type).toStrictEqual('String');
44+
expect(uuid.type).toStrictEqual('Uuid');
4545
});
4646

4747
it('should not be set as required', () => {

0 commit comments

Comments
 (0)