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

Commit 513aeb16 by Jonathan Crossman

- adding second test for object style definition

- removing incomplete dataType check
- styling code more like the rest of the project
1 parent 94ce9588
...@@ -54,11 +54,6 @@ module.exports = (function() { ...@@ -54,11 +54,6 @@ 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
} }
......
...@@ -151,17 +151,15 @@ module.exports = (function() { ...@@ -151,17 +151,15 @@ module.exports = (function() {
options = options || {} options = options || {}
var globalOptions = this.options var globalOptions = this.options
for (var name in attributes) { // If you don't specify a valid data type lets help you debug it
if (attributes.hasOwnProperty(name)) { Utils._.each(attributes, function(dataType, name){
var dataType = attributes[name]
if (Utils.isHash(dataType)) { if (Utils.isHash(dataType)) {
dataType = dataType.type dataType = dataType.type
} }
if (dataType === undefined) { if (dataType === undefined) {
throw new Error('Unrecognized data type for field '+ name) throw new Error('Unrecognized data type for field '+ name)
} }
} })
}
if (globalOptions.define) { if (globalOptions.define) {
options = Utils._.extend({}, globalOptions.define, options) options = Utils._.extend({}, globalOptions.define, options)
......
...@@ -215,6 +215,12 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() { ...@@ -215,6 +215,12 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
activity_date: Sequelize.DATe activity_date: Sequelize.DATe
}) })
}.bind(this), 'Unrecognized data type for field activity_date') }.bind(this), 'Unrecognized data type for field activity_date')
Helpers.assertException(function() {
this.sequelize.define('UserBadDataType', {
activity_date: {type: Sequelize.DATe}
})
}.bind(this), 'Unrecognized data type for field activity_date')
}) })
it('sets a 64 bit int in bigint', function(done) { it('sets a 64 bit int in bigint', function(done) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!