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

Commit 07e72bdd by Mick Hansen

create quoteTable method

1 parent b58e5eda
...@@ -139,7 +139,7 @@ module.exports = (function() { ...@@ -139,7 +139,7 @@ module.exports = (function() {
} }
var replacements = { var replacements = {
table: this.quoteIdentifiers(tableName), table: this.quoteTable(tableName),
values: values.join(","), values: values.join(","),
where: this.getWhereConditions(where) where: this.getWhereConditions(where)
} }
......
...@@ -428,6 +428,10 @@ module.exports = (function() { ...@@ -428,6 +428,10 @@ module.exports = (function() {
quoteIdentifiers: function(identifiers, force) { quoteIdentifiers: function(identifiers, force) {
return identifiers.split('.').map(function(v) { return this.quoteIdentifier(v, force) }.bind(this)).join('.') return identifiers.split('.').map(function(v) { return this.quoteIdentifier(v, force) }.bind(this)).join('.')
}, },
quoteTable: function(table) {
return this.quoteIdentifier(table)
},
/** /**
* Generates an SQL query that returns all foreign keys of a table. * Generates an SQL query that returns all foreign keys of a table.
......
...@@ -835,6 +835,10 @@ module.exports = (function() { ...@@ -835,6 +835,10 @@ module.exports = (function() {
return identifiers.split('.').map(function(t) { return this.quoteIdentifier(t, force) }.bind(this)).join('.') return identifiers.split('.').map(function(t) { return this.quoteIdentifier(t, force) }.bind(this)).join('.')
}, },
quoteTable: function(table) {
return this.quoteIdentifiers(table)
},
/** /**
* Generates an SQL query that returns all foreign keys of a table. * Generates an SQL query that returns all foreign keys of a table.
* *
......
...@@ -411,6 +411,10 @@ module.exports = (function() { ...@@ -411,6 +411,10 @@ module.exports = (function() {
return identifiers.split('.').map(function(v) { return this.quoteIdentifier(v, force) }.bind(this)).join('.') return identifiers.split('.').map(function(v) { return this.quoteIdentifier(v, force) }.bind(this)).join('.')
}, },
quoteTable: function(table) {
return this.quoteIdentifier(table)
},
/** /**
* Generates an SQL query that returns all foreign keys of a table. * Generates an SQL query that returns all foreign keys of a table.
* *
......
...@@ -1252,10 +1252,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1252,10 +1252,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
} }
}) })
it("should be able to create and update records under any valid schematic", function(done){ it.only("should be able to create and update records under any valid schematic", function(done){
var self = this var self = this
self.UserPublic.sync({ force: true }).success(function(UserPublicSync){ self.UserPublic.sync({ force: true }).done(function(err, UserPublicSync){
expect(err).not.to.be.ok
UserPublicSync.create({age: 3}).on('sql', function(UserPublic){ UserPublicSync.create({age: 3}).on('sql', function(UserPublic){
self.UserSpecialSync.schema('special').create({age: 3}) self.UserSpecialSync.schema('special').create({age: 3})
.on('sql', function(UserSpecial){ .on('sql', function(UserSpecial){
...@@ -1275,7 +1276,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1275,7 +1276,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(UserPublic.indexOf('INSERT INTO `UserPublics`')).to.be.above(-1) expect(UserPublic.indexOf('INSERT INTO `UserPublics`')).to.be.above(-1)
} }
}) })
.success(function(UserSpecial){ .done(function(err, UserSpecial){
expect(err).not.to.be.ok
UserSpecial.updateAttributes({age: 5}) UserSpecial.updateAttributes({age: 5})
.on('sql', function(user){ .on('sql', function(user){
expect(user).to.exist expect(user).to.exist
...@@ -1285,8 +1287,13 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1285,8 +1287,13 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(user.indexOf('UPDATE `special.UserSpecials`')).to.be.above(-1) expect(user.indexOf('UPDATE `special.UserSpecials`')).to.be.above(-1)
} }
done() done()
}).error(function (err) {
console.log(err)
expect(err).not.to.be.ok
}) })
}) })
}).error(function (err) {
expect(err).not.to.be.ok
}) })
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!