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

Commit e2c17b58 by Jisoo Park

Local options overwite global

Replaced Utils.merge with Utils._.extend
1 parent 3eb036f5
...@@ -26,7 +26,7 @@ module.exports = (function() { ...@@ -26,7 +26,7 @@ module.exports = (function() {
options.where[self.__factory.target.tableName+"."+index] = value; options.where[self.__factory.target.tableName+"."+index] = value;
}); });
options.where = options.where ? Utils.merge(options.where, where) : where options.where = options.where ? Utils._.extend(options.where, where) : where
} else { } else {
options.where = where; options.where = where;
} }
......
...@@ -11,7 +11,7 @@ module.exports = (function() { ...@@ -11,7 +11,7 @@ module.exports = (function() {
where[this.__factory.identifier] = this.instance.id where[this.__factory.identifier] = this.instance.id
options.where = options.where ? Utils.merge(options.where, where) : where options.where = options.where ? Utils._.extend(options.where, where) : where
return this.__factory.target.findAll(options) return this.__factory.target.findAll(options)
} }
......
...@@ -60,7 +60,7 @@ module.exports = (function() { ...@@ -60,7 +60,7 @@ module.exports = (function() {
} }
DAOFactory.prototype.sync = function(options) { DAOFactory.prototype.sync = function(options) {
options = Utils.merge(options || {}, this.options) options = Utils._.extend(options || {}, this.options)
var self = this var self = this
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
......
...@@ -91,7 +91,7 @@ module.exports = (function() { ...@@ -91,7 +91,7 @@ module.exports = (function() {
Sequelize.prototype.define = function(daoName, attributes, options) { Sequelize.prototype.define = function(daoName, attributes, options) {
options = options || {} options = options || {}
if(this.options.define) { if(this.options.define) {
options = Sequelize.Utils.merge(options, this.options.define) options = Utils._.extend({}, this.options.define, options)
} }
options.omitNull = this.options.omitNull options.omitNull = this.options.omitNull
...@@ -133,7 +133,7 @@ module.exports = (function() { ...@@ -133,7 +133,7 @@ module.exports = (function() {
options = options || {} options = options || {}
if(this.options.sync) { if(this.options.sync) {
options = Sequelize.Utils.merge(options, this.options.sync) options = Utils._.extend({}, this.options.sync, options)
} }
var chainer = new Utils.QueryChainer() var chainer = new Utils.QueryChainer()
......
...@@ -92,13 +92,6 @@ var Utils = module.exports = { ...@@ -92,13 +92,6 @@ var Utils = module.exports = {
return Utils.Lingo.en.isPlural(s) ? s : Utils.Lingo.en.pluralize(s) return Utils.Lingo.en.isPlural(s) ? s : Utils.Lingo.en.pluralize(s)
}, },
merge: function(a, b){
for(var key in b) {
a[key] = b[key]
}
return a
},
removeCommentsFromFunctionString: function(s) { removeCommentsFromFunctionString: function(s) {
s = s.replace(/\s*(\/\/.*)/g, '') s = s.replace(/\s*(\/\/.*)/g, '')
s = s.replace(/(\/\*[\n\r\s\S]*?\*\/)/mg, '') s = s.replace(/(\/\*[\n\r\s\S]*?\*\/)/mg, '')
......
...@@ -40,6 +40,12 @@ describe('Sequelize', function() { ...@@ -40,6 +40,12 @@ describe('Sequelize', function() {
sequelize.define('foo', { title: Sequelize.STRING }) sequelize.define('foo', { title: Sequelize.STRING })
expect(sequelize.daoFactoryManager.all.length).toEqual(1) expect(sequelize.daoFactoryManager.all.length).toEqual(1)
}) })
it("overwrites global options", function() {
setup({ define: { collate: 'utf8_general_ci' } })
var DAO = sequelize.define('foo', {bar: Sequelize.STRING}, {collate: 'utf8_bin'})
expect(DAO.options.collate).toEqual('utf8_bin')
})
}) })
describe('sync', function() { describe('sync', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!