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

Commit 586a854c by sdepold

formatting

1 parent 473bce05
var Utils = require("./utils") var Utils = require("./utils")
, Mixin = require("./associations/mixin") , Mixin = require("./associations/mixin")
, DataTypes = require("./data-types")
, Validator = require("validator") , Validator = require("validator")
module.exports = (function() { module.exports = (function() {
......
var Utils = require("../../utils") var Utils = require("../../utils")
, DataTypes = require("../../data-types")
, util = require("util") , util = require("util")
module.exports = (function() { module.exports = (function() {
...@@ -271,14 +272,26 @@ module.exports = (function() { ...@@ -271,14 +272,26 @@ module.exports = (function() {
var template = "<%= type %>" var template = "<%= type %>"
, replacements = { type: dataType.type } , replacements = { type: dataType.type }
if(dataType.hasOwnProperty('allowNull') && (!dataType.allowNull)) template += " NOT NULL" if(dataType.hasOwnProperty('allowNull') && (!dataType.allowNull)) {
if(dataType.autoIncrement) template +=" auto_increment" template += " NOT NULL"
if(dataType.defaultValue != undefined) { }
if(dataType.autoIncrement) {
template +=" auto_increment"
}
if((dataType.defaultValue != undefined) && (dataType.defaultValue != DataTypes.NOW)) {
template += " DEFAULT <%= defaultValue %>" template += " DEFAULT <%= defaultValue %>"
replacements.defaultValue = Utils.escape(dataType.defaultValue) replacements.defaultValue = Utils.escape(dataType.defaultValue)
} }
if(dataType.unique) template += " UNIQUE"
if(dataType.primaryKey) template += " PRIMARY KEY" if(dataType.unique) {
template += " UNIQUE"
}
if(dataType.primaryKey) {
template += " PRIMARY KEY"
}
result[name] = Utils._.template(template)(replacements) result[name] = Utils._.template(template)(replacements)
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!