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

Commit f46fcabf by Mick Hansen

fix(associations/hasOne): hasOne.createAssociation should use create directly (i…

…nstead of a create + set call), fixes #2304
1 parent 6343ed2f
Showing with 6 additions and 10 deletions
......@@ -143,17 +143,13 @@ module.exports = (function() {
HasOne.prototype.injectCreator = function(instancePrototype) {
var association = this;
instancePrototype[this.accessors.create] = function(values, fieldsOrOptions) {
var instance = this
, options = {};
if ((fieldsOrOptions || {}).transaction instanceof Transaction) {
options.transaction = fieldsOrOptions.transaction;
}
instancePrototype[this.accessors.create] = function(values, options) {
var instance = this;
options = options || {};
return association.target.create(values, fieldsOrOptions).then(function(associationInstance) {
return instance[association.accessors.set](associationInstance, options);
});
values[association.identifier] = instance.get(association.sourceIdentifier);
if (options.fields) options.fields.push(association.identifier);
return association.target.create(values, options);
};
return this;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!