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

Commit a0f0f5b2 by tngraessler

MySQL: Unique key index column names now quoted


https://github.com/sequelize/sequelize/issues/1753
1 parent 6996c1cc
Showing with 9 additions and 1 deletions
......@@ -25,6 +25,8 @@ module.exports = (function() {
charset: null
}, options || {})
var self = this;
var query = "CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>)<%= comment %> ENGINE=<%= engine %> <%= charset %> <%= collation %>"
, primaryKeys = []
, foreignKeys = {}
......@@ -68,7 +70,13 @@ module.exports = (function() {
if (!!options.uniqueKeys) {
Utils._.each(options.uniqueKeys, function(columns) {
values.attributes += ", UNIQUE uniq_" + tableName + '_' + columns.fields.join('_') + " (" + columns.fields.join(', ') + ")"
values.attributes += ", UNIQUE uniq_" + tableName + '_' + columns.fields.join('_') + " (";
var i = 0;
Utils._.each(columns.fields, function(field) {
if(i++ > 0) values.attributes += ", ";
values.attributes += self.quoteIdentifier(field);
});
values.attributes += ")";
})
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!