Repository navigation
fix(postgresql): typed filters keep braces in string literals (#70) - #71
Merged
Merged
Conversation
Literals escape { and } as {{ and }} for expression templates, which
unescape them when resolved. A typed filter goes through the filter
resolver instead, which has no {{ escape because '{{1,2},{3,4}}' is a
valid array literal, so the braces stayed doubled: x.Code != "{draft}"
scaffolded "Code" <> '{{draft}}', a different value, and rows whose
code is {draft} were indexed although the filter excludes them.
TranslatePredicate now undoes the escape inside string literals. The
filter resolver never reads a brace inside a literal as a placeholder,
so the single brace is safe there.
Verified by reverting the translator: the new test, covering an index
filter and an exclusion-constraint filter, fails.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 19, 2026
Merged
The brace unescape now wraps the null-aware VisitPredicate; both test groups and both changelog entries are kept. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
Closes #70
Problem
HasComplexIndex(x => x.Code, x => x.Code != "{draft}")scaffoldedWHERE "Code" <> '{{draft}}'. PostgreSQL compares against{{draft}}, a different value, so rows whose code is{draft}are indexed, and constrained when the index is unique, although the filter excludes them. The same forHasFilter<T>,AddComplexIndexFilter<T>and typed exclusion-constraint filters. Silent since 5.2.0.The translator's literal writer escapes braces for expression templates, which are unescaped when resolved. Filters go through
ResolveFilter, which has no{{escape on purpose ('{{1,2},{3,4}}'is an array literal), so the escape was never undone.Change
NpgsqlLinqIndexTranslator.TranslatePredicateundoes the brace escape inside single-quoted literals of the predicate it produced.ResolveFilternever reads a brace inside a literal as a placeholder, so a single brace is safe there. Typed expression indexes keep the escape they need.Changelogs: a
### Changed answersrow for #70 in the 5.5.0 entry.Merge note: #69 adds the same
### Changed answers/### Changedheadings to the 5.5.0 changelog entries. Whichever merges second needs a trivial rebase ofCHANGELOG.mdand the PostgreSQL package changelog (both rows under one heading); I'll do it when the first one lands.Tests
NpgsqlTypedFilterTests.Brace_in_literal_is_kept: an index filter with{draft}and{{1,2}}literals and an exclusion filter with}{render as written.'{{draft}}').🤖 Generated with Claude Code