Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rows to hasMany join table in order provided #862

Merged
merged 1 commit into from
Jun 27, 2023
Merged

Conversation

dxg
Copy link
Collaborator

@dxg dxg commented Jun 27, 2023

Previously, they were added in reverse order

Previously, they were added in reverse order

var Association = Associations.pop();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the offending line. Rather than switch to .shift I decided to simplify by leveraging async.eachSeries.

return cb();
}

var other = associations.pop();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed the order in which hasOne associations are saved from reverse to provided order.
No tests for this as it doesn't really affect anything.


args.push(next);
Copy link
Collaborator Author

@dxg dxg Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bit complicated and it wasn't clear what it's actually doing (there's an optional opts parameter which gets passed to the hook).
Rewritten to make it more explicit.

@dxg dxg merged commit 2e3d690 into master Jun 27, 2023
@dxg dxg deleted the has_many_join_order branch June 27, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant