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

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'); ...@@ -4,7 +4,6 @@ var DataTypes = require('../../data-types');
//drop table Group //drop table Group
DataTypes.BOOLEAN = 'BIT'; DataTypes.BOOLEAN = 'BIT';
DataTypes.DATE = 'DATETIME2';
DataTypes.NOW = 'GETDATE()'; DataTypes.NOW = 'GETDATE()';
DataTypes.UUID = 'UNIQUEIDENTIFIER'; DataTypes.UUID = 'UNIQUEIDENTIFIER';
DataTypes.BLOB = 'VARBINARY(MAX)'; DataTypes.BLOB = 'VARBINARY(MAX)';
...@@ -27,4 +26,4 @@ DataTypes.STRING.prototype = { ...@@ -27,4 +26,4 @@ DataTypes.STRING.prototype = {
} }
}; };
module.exports = DataTypes; module.exports = DataTypes;
\ No newline at end of file
...@@ -303,6 +303,14 @@ module.exports = { ...@@ -303,6 +303,14 @@ module.exports = {
"END;"].join(' '); "END;"].join(' ');
}, },
dataTypeMapping: function(tableName, attr, dataType) {
if (Utils._.includes(dataType, 'DATETIME')) {
dataType = dataType.replace(/DATETIME/, 'DATETIME2');
}
return dataType;
},
getCreateTableSql: function(tableName, attributes, options) { getCreateTableSql: function(tableName, attributes, options) {
var query = "CREATE TABLE <%= tableName %> (<%= attributes%>)"; var query = "CREATE TABLE <%= tableName %> (<%= attributes%>)";
var attrStr = [] var attrStr = []
...@@ -312,14 +320,16 @@ module.exports = { ...@@ -312,14 +320,16 @@ module.exports = {
})); }));
for (var attr in attributes) { for (var attr in attributes) {
var dataType = attributes[attr]; var dataType = this.dataTypeMapping(tableName, attr, attributes[attr]);
attrStr.push(quoteIdentifier(attr) + " " + dataType); attrStr.push(quoteIdentifier(attr) + " " + dataType);
} }
var values = { var values = {
unquotedTable: tableName, unquotedTable: tableName,
tableName: quoteIdentifier(tableName.toString()), tableName: quoteIdentifier(tableName.toString()),
attributes: attrStr.join(", ") attributes: attrStr.join(", ")
}; };
query = addTableExistsWrapper(query); query = addTableExistsWrapper(query);
return Utils._.template(query)(values).trim() + ";"; 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!