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

Commit 69dc2200 by Matt Broadstone

fix date fields include test

DataTypes.DATE was set to "DATETIME2", which has implications for internal
sequelize code. Instead we should be using a data type mapping, like postgres
support.
1 parent 76ec38c3
......@@ -4,7 +4,6 @@ var DataTypes = require('../../data-types');
//drop table Group
DataTypes.BOOLEAN = 'BIT';
DataTypes.DATE = 'DATETIME2';
DataTypes.NOW = 'GETDATE()';
DataTypes.UUID = 'UNIQUEIDENTIFIER';
DataTypes.BLOB = 'VARBINARY(MAX)';
......@@ -27,4 +26,4 @@ DataTypes.STRING.prototype = {
}
};
module.exports = DataTypes;
\ No newline at end of file
module.exports = DataTypes;
......@@ -303,6 +303,14 @@ module.exports = {
"END;"].join(' ');
},
dataTypeMapping: function(tableName, attr, dataType) {
if (Utils._.includes(dataType, 'DATETIME')) {
dataType = dataType.replace(/DATETIME/, 'DATETIME2');
}
return dataType;
},
getCreateTableSql: function(tableName, attributes, options) {
var query = "CREATE TABLE <%= tableName %> (<%= attributes%>)";
var attrStr = []
......@@ -312,14 +320,16 @@ module.exports = {
}));
for (var attr in attributes) {
var dataType = attributes[attr];
var dataType = this.dataTypeMapping(tableName, attr, attributes[attr]);
attrStr.push(quoteIdentifier(attr) + " " + dataType);
}
var values = {
unquotedTable: tableName,
tableName: quoteIdentifier(tableName.toString()),
attributes: attrStr.join(", ")
};
query = addTableExistsWrapper(query);
return Utils._.template(query)(values).trim() + ";";
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!