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

Commit 3ba08e67 by Mick Hansen

fix(model/attributes): fix mapping back serial values from postgres inserts with aliased fields

1 parent 7f43820e
......@@ -151,7 +151,11 @@ module.exports = (function() {
if (!!self.callee.Model && !!self.callee.Model.rawAttributes && !!self.callee.Model.rawAttributes[key] && !!self.callee.Model.rawAttributes[key].type && self.callee.Model.rawAttributes[key].type.toString() === DataTypes.HSTORE.toString()) {
record = hstore.parse(record);
}
self.callee.dataValues[key] = record;
var attr = Utils._.find(self.callee.Model.rawAttributes, function (attribute) {
return attribute.fieldName === key || attribute.field === key;
});
self.callee.dataValues[attr && attr.fieldName || key] = record;
}
}
}
......
......@@ -148,6 +148,15 @@ describe(Support.getTestDialectTeaser("Model"), function () {
});
});
it('should make the aliased auto incremented primary key available after create', function () {
var self = this;
return this.User.create({
name: 'Barfoo'
}).then(function (user) {
expect(user.get('id')).to.be.ok;
});
});
it('should work with where on includes for find', function () {
var self = this;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!