Skip to content

Commit 7972ed9

Browse files
committed
Fixes DataType STRING.BINARY
1 parent 75d1cdc commit 7972ed9

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

lib/type-mapper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ class TypeMapper {
240240
// ----------------------------------------------------------------------
241241
case 'STRING': {
242242
result = { ...STRING };
243-
let length = properties.type.options && properties.type.options.length;
244243

245244
// use available length aliases if length property matches
245+
let length = properties.type.options && properties.type.options.length;
246+
246247
length = STRING_LENGTHS[length] || length;
247248
if (length) result.maxLength = length;
248249

test/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = sequelize => {
8282
}
8383

8484
if (supportedDataType('UUIDV4')) {
85-
Model.rawAttributes.STRING_DOT_BINARY = {
85+
Model.rawAttributes.UUIDV4 = {
8686
type: DataTypes.UUID,
8787
};
8888
}

test/strategies/json-schema-v7-strategy.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ describe('JsonSchema7Strategy', function() {
6666
});
6767
});
6868

69+
describe('STRING_DOT_BINARY', function() {
70+
it("has property 'type' of type 'string'", function() {
71+
expect(schema.properties.STRING_DOT_BINARY.type).toEqual('string');
72+
});
73+
74+
it("has property 'format' of type 'binary'", function() {
75+
expect(schema.properties.STRING_DOT_BINARY.format).toEqual('binary');
76+
});
77+
});
78+
6979
describe('STRING_ALLOWNULL', function() {
7080
it("has property 'type' of type 'array'", function() {
7181
expect(Array.isArray(schema.properties.STRING_ALLOWNULL.type)).toBe(true);

test/strategies/openapi-v3-stragegy.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ describe('OpenApi3Strategy', function() {
6060
});
6161
});
6262

63+
describe('STRING_DOT_BINARY', function() {
64+
it("has property 'type' of type 'string'", function() {
65+
expect(userSchema.properties.STRING_DOT_BINARY.type).toEqual('string');
66+
});
67+
68+
it("has property 'format' of type 'binary'", function() {
69+
expect(userSchema.properties.STRING_DOT_BINARY.format).toEqual('binary');
70+
});
71+
});
72+
6373
describe('STRING_ALLOWNULL', function() {
6474
it("has property 'type' of type 'string'", function() {
6575
expect(userSchema.properties.STRING_ALLOWNULL.type).toEqual('string');
6676
});
6777

6878
it("has property 'nullable' of type 'boolean'", function() {
69-
expect(userSchema.properties.STRING_ALLOWNULL).toHaveProperty('nullable');
7079
expect(typeof userSchema.properties.STRING_ALLOWNULL.nullable).toEqual('boolean');
7180
});
7281
});

0 commit comments

Comments
 (0)