Repository navigation
Make the :preload_order option in Ecto.Schema.has_many/3 not take precedence over custom preload queries - #4675
Merged
Conversation
Member
|
The integration tests are failing, can you please take a look? |
Member
|
Are the formatting changes necessary to shim into this pr? |
Member
|
@tarzan I have formatted those files on main, so you can rebase and it should keep the PR tiny! |
…ith custom queries
Contributor
Author
This should be fixed now. I rebased the code as well. Can you re-run the workflow? |
Member
|
💚 💙 💜 💛 ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #4535
Sorry about the whitespace changes - mix formatter automatically runs in my editor, do I need to revert those changes?
Key Changes:
Core Implementation (lib/ecto/repo/preloader.ex)
Added a new clause to the
add_preload_order/2function that checks if the query already has order_by clauses:This ensures that when a custom query with its own ordering is provided, the :preload_order is not applied, allowing the custom order to take precedence.
Documentation Updates (lib/ecto/schema.ex)
Updated the documentation for :preload_order in both has_many/3 and many_to_many/3 to clarify the new behavior:
Test Coverage (integration_test/cases/preload.exs)
Added a comprehensive test case (custom query order_by overrides preload_order) that verifies:
Changelog (CHANGELOG.md)
Added an entry documenting this enhancement for the next release.