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

Commit 3a149658 by Mick Hansen

fixes queryInterface.addIndex for reserved keywords

1 parent 441d013b
...@@ -243,7 +243,7 @@ module.exports = (function() { ...@@ -243,7 +243,7 @@ module.exports = (function() {
addIndexQuery: function(tableName, attributes, options) { addIndexQuery: function(tableName, attributes, options) {
var transformedAttributes = attributes.map(function(attribute) { var transformedAttributes = attributes.map(function(attribute) {
if(typeof attribute === 'string') { if(typeof attribute === 'string') {
return attribute return this.quoteIdentifier(attribute)
} else { } else {
var result = "" var result = ""
...@@ -251,7 +251,7 @@ module.exports = (function() { ...@@ -251,7 +251,7 @@ module.exports = (function() {
throw new Error('The following index attribute has no attribute: ' + util.inspect(attribute)) throw new Error('The following index attribute has no attribute: ' + util.inspect(attribute))
} }
result += attribute.attribute result += this.quoteIdentifier(attribute.attribute)
if (attribute.length) { if (attribute.length) {
result += '(' + attribute.length + ')' result += '(' + attribute.length + ')'
......
...@@ -71,7 +71,8 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () { ...@@ -71,7 +71,8 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () {
this.queryInterface.dropTable('Users').success(function() { this.queryInterface.dropTable('Users').success(function() {
self.queryInterface.createTable('Users', { self.queryInterface.createTable('Users', {
username: DataTypes.STRING, username: DataTypes.STRING,
isAdmin: DataTypes.BOOLEAN isAdmin: DataTypes.BOOLEAN,
from: DataTypes.STRING
}).success(function() { }).success(function() {
done() done()
}) })
...@@ -105,6 +106,14 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () { ...@@ -105,6 +106,14 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () {
}) })
}) })
}) })
it('does not fail on reserved keywords', function (done) {
this.queryInterface.addIndex('Users', ['from']).done(function(err) {
expect(err).to.be.null
done()
})
})
}) })
describe('describeTable', function() { describe('describeTable', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!