Fix GIN index detection for views#3879
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes PostgreSQL array Contains translation to detect modeled GIN indexes even when the entity is mapped via ToView(), by looking up indexes from the mapped CLR property’s model metadata rather than from table-only metadata. This ensures view-mapped queries can still translate to the @> containment operator (which can leverage the underlying index) instead of falling back to ANY.
Changes:
- Update GIN index detection for array-column
Containstranslation to work for both table and view mappings by inspecting indexes via the column’s mapped property metadata. - Add a focused regression test asserting that
ToView()mappings still translateContainsto@>when a GIN index is configured.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs | Adds a regression test covering ToView() + GIN index detection for array Contains translation. |
| src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs | Adjusts GIN index detection logic to use property-based index metadata (works for views) instead of table index metadata. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Low
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.
ToViewmappings use view columns rather than table columns, so the index-aware arrayContainstranslation did not find a modeled GIN index and fell back toANY.Inspect indexes through the column property's model metadata, which supports both table and view mappings while retaining the existing first-indexed-property and GIN-method requirements. Adds a focused
ToViewtranslation regression test.Fixes #3829