不要怂,就是干,撸起袖子干!

Commit c90c8d5c by u9r52sld Committed by Sushant

fix: throw when type of array values is not defined (#9649)

1 parent fea6db4a
...@@ -1095,9 +1095,14 @@ class Sequelize { ...@@ -1095,9 +1095,14 @@ class Sequelize {
type = dialectTypes[type.key].extend(type); type = dialectTypes[type.key].extend(type);
} }
if (type instanceof DataTypes.ARRAY && dialectTypes[type.type.key]) { if (type instanceof DataTypes.ARRAY) {
type.type = dialectTypes[type.type.key].extend(type.type); if (!type.type) {
throw new Error('ARRAY is missing type definition for its values.');
} else if (dialectTypes[type.type.key]) {
type.type = dialectTypes[type.type.key].extend(type.type);
}
} }
return type; return type;
} }
......
...@@ -1206,6 +1206,16 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -1206,6 +1206,16 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
}); });
describe('define', () => { describe('define', () => {
it('raises an error if no values are defined', function() {
expect(() => {
this.sequelize.define('omnomnom', {
bla: { type: DataTypes.ARRAY }
});
}).to.throw(Error, 'ARRAY is missing type definition for its values.');
});
});
describe('define', () => {
[ [
{ type: DataTypes.ENUM, values: ['scheduled', 'active', 'finished']}, { type: DataTypes.ENUM, values: ['scheduled', 'active', 'finished']},
DataTypes.ENUM('scheduled', 'active', 'finished') DataTypes.ENUM('scheduled', 'active', 'finished')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!