Add throwOnRedundantOrderBy detection#107
Merged
Merged
Conversation
Opt-in flag on UseDefaultOrderBy that throws when a query explicitly orders by exactly the same properties, sequence, and directions as the configured default ordering. Primarily useful in tests to find query ordering left over from before the default ordering was configured. RedundantOrder walks the outermost ordering chain of the query spine and compares the collected clauses against the entity configuration. It bails out without throwing on anything that cannot be represented as configuration, such as comparer overloads or non property key selectors. Both Queryable and Enumerable ordering are handled, so nested collection ordering in Include() is checked the same way. The flag is read from IDbContextOptions per query compilation rather than cached per DbContext type, since the interceptor is a singleton shared across contexts and a type keyed cache would be wrong when the same context type is built with different options.
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.
Opt-in flag on UseDefaultOrderBy that throws when a query explicitly orders by exactly the same properties, sequence, and directions as the configured default ordering. Primarily useful in tests to find query ordering left over from before the default ordering was configured.
RedundantOrder walks the outermost ordering chain of the query spine and compares the collected clauses against the entity configuration. It bails out without throwing on anything that cannot be represented as configuration, such as comparer overloads or non property key selectors. Both Queryable and Enumerable ordering are handled, so nested collection ordering in Include() is checked the same way.
The flag is read from IDbContextOptions per query compilation rather than cached per DbContext type, since the interceptor is a singleton shared across contexts and a type keyed cache would be wrong when the same context type is built with different options.