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

Commit b0709fde by Sascha Depold

specify disableTableNameModification in order to let table names as passed

1 parent 20bc8b0b
...@@ -22,7 +22,9 @@ var injectSQL = function(instance) { ...@@ -22,7 +22,9 @@ var injectSQL = function(instance) {
}, },
asTableName: function(name) { asTableName: function(name) {
return instance.Inflection.pluralize(name) return instance.options.disableTableNameModification
? name
: instance.Inflection.pluralize(name)
}, },
asSqlDate: function(date) { asSqlDate: function(date) {
...@@ -210,6 +212,7 @@ var injectBasics = function(instance) { ...@@ -210,6 +212,7 @@ var injectBasics = function(instance) {
var Helper = function(Sequelize) { var Helper = function(Sequelize) {
this.Sequelize = Sequelize this.Sequelize = Sequelize
this.Inflection = require(__dirname + "/../inflection/inflection") this.Inflection = require(__dirname + "/../inflection/inflection")
this.options = {}
injectBasics(this) injectBasics(this)
injectSQL(this) injectSQL(this)
......
var Sequelize = function(database, username, password, options) { var Sequelize = function(database, username, password, options) {
options = options || {} options = options || {}
this.tables = {}
this.options = Sequelize.Helper.Hash.without(options, ["host", "port", "disableTableNameModification"])
this.config = { this.config = {
database: database, database: database,
username: username, username: username,
...@@ -7,8 +10,10 @@ var Sequelize = function(database, username, password, options) { ...@@ -7,8 +10,10 @@ var Sequelize = function(database, username, password, options) {
host : options.host || 'localhost', host : options.host || 'localhost',
port : options.port || 3306 port : options.port || 3306
} }
this.tables = {}
this.options = Sequelize.Helper.Hash.without(options, ["host", "port"]) Sequelize.Helper.configure({
disableTableNameModification: (options.disableTableNameModification || false)
})
} }
var classMethods = { var classMethods = {
......
...@@ -17,6 +17,13 @@ module.exports = { ...@@ -17,6 +17,13 @@ module.exports = {
assert.equal(h.SQL.asTableName('Child'), 'Children') assert.equal(h.SQL.asTableName('Child'), 'Children')
assert.equal(h.SQL.asTableName('Mouse'), 'Mice') assert.equal(h.SQL.asTableName('Mouse'), 'Mice')
}, },
'SQL: asTableName with options': function(assert) {
h.configure({ disableTableNameModification: true })
assert.equal(h.SQL.asTableName('User'), 'User')
assert.equal(h.SQL.asTableName('Child'), 'Child')
assert.equal(h.SQL.asTableName('Mouse'), 'Mouse')
h.configure({ disableTableNameModification: false })
},
'SQL: asSqlDate': function(assert) { 'SQL: asSqlDate': function(assert) {
var d = new Date(Date.parse("Tue, 1 Jan 2000 00:00:00 GMT")) var d = new Date(Date.parse("Tue, 1 Jan 2000 00:00:00 GMT"))
assert.equal(h.SQL.asSqlDate(d), '2000-01-01 01:00:00') assert.equal(h.SQL.asSqlDate(d), '2000-01-01 01:00:00')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!