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

Commit f1f5af6c by Sascha Depold

Merge pull request #375 from adamsch1/master

Clearer error if you have a typo on the column data type
2 parents 9289a2f7 a6eadf1b
Showing with 16 additions and 0 deletions
...@@ -49,6 +49,8 @@ module.exports = (function() { ...@@ -49,6 +49,8 @@ module.exports = (function() {
this.primaryKeys = {}; this.primaryKeys = {};
Utils._.each(this.attributes, function(dataTypeString, attributeName) { Utils._.each(this.attributes, function(dataTypeString, attributeName) {
// If you don't specify a valid data type lets help you debug it
if( dataTypeString === undefined ) throw new Error("Unrecognized data type for field " + attributeName );
if((attributeName != 'id') && (dataTypeString.indexOf('PRIMARY KEY') !== -1)) { if((attributeName != 'id') && (dataTypeString.indexOf('PRIMARY KEY') !== -1)) {
self.primaryKeys[attributeName] = dataTypeString self.primaryKeys[attributeName] = dataTypeString
} }
......
...@@ -205,6 +205,20 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() { ...@@ -205,6 +205,20 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
}) })
}) })
it('raises an error if you mess up the datatype', function(done) {
try {
var User = this.sequelize.define('UserBadDataType', {
activity_date: Sequelize.DATe
});
done()
}
catch( e ) {
expect(e.message).toEqual('Unrecognized data type for field activity_date')
done()
}
})
it('sets a 64 bit int in bigint', function(done) { it('sets a 64 bit int in bigint', function(done) {
var User = this.sequelize.define('UserWithBigIntFields', { var User = this.sequelize.define('UserWithBigIntFields', {
big: Sequelize.BIGINT big: Sequelize.BIGINT
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!