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

Commit 1d87f43b by Sascha Depold

don't omit null for associated foreign keys

1 parent e8597259
...@@ -22,7 +22,7 @@ module.exports = (function() { ...@@ -22,7 +22,7 @@ module.exports = (function() {
// clear the old associations // clear the old associations
oldAssociations.forEach(function(associatedObject) { oldAssociations.forEach(function(associatedObject) {
associatedObject[self.__factory.identifier] = options.omitNull ? '' : null associatedObject[self.__factory.identifier] = /*options.omitNull ? '' :*/ null
chainer.add(associatedObject.save()) chainer.add(associatedObject.save())
}) })
......
...@@ -54,7 +54,7 @@ module.exports = (function() { ...@@ -54,7 +54,7 @@ module.exports = (function() {
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
obj[self.accessors.get]().success(function(oldObj) { obj[self.accessors.get]().success(function(oldObj) {
if(oldObj) { if(oldObj) {
oldObj[self.identifier] = options.omitNull ? '' : null; oldObj[self.identifier] = /*options.omitNull ? '' :*/ null;
oldObj.save() oldObj.save()
} }
......
...@@ -119,7 +119,7 @@ var Utils = module.exports = { ...@@ -119,7 +119,7 @@ var Utils = module.exports = {
var _hash = {} var _hash = {}
Utils._.each(hash, function(val, key) { Utils._.each(hash, function(val, key) {
if(val !== null && val !== undefined) { if (key.match(/Id$/) || ((val !== null) && (val !== undefined))) {
_hash[key] = val; _hash[key] = val;
} }
}) })
......
...@@ -154,7 +154,7 @@ describe('HasMany', function() { ...@@ -154,7 +154,7 @@ describe('HasMany', function() {
}) })
it("clears associations when passing null to the set-method with omitNull set to true", function(done) { it("clears associations when passing null to the set-method with omitNull set to true", function(done) {
this.sequelize.options.omitNull = true; this.sequelize.options.omitNull = true
var User = this.sequelize.define('User', { username: Sequelize.STRING }) var User = this.sequelize.define('User', { username: Sequelize.STRING })
, Task = this.sequelize.define('Task', { title: Sequelize.STRING }) , Task = this.sequelize.define('Task', { title: Sequelize.STRING })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!