Repository navigation
fix: reject a collation on a string set column unless it compares bytes (#483) - #492
Merged
CaffeinatedCoder merged 3 commits intoOct 26, 2026
Conversation
…es (#483) PostgreSQL compares text[] elements with the column's collation, memory ordinally. Under a nondeterministic collation A equals a: on a case-insensitive StringSet column Contains("a") matched {A}, IsSubsetOf, Overlaps and == agreed with it, and ExecuteUpdate with Remove("a") stored {} where memory keeps {A}. Translating with COLLATE "C" was measured and rejected: the GIN index carries the column's collation, so a collated operand turns every indexed @> into a sequential scan, on an en_US column too (PostgreSQL 16 and 18). So a model-finalizing convention, added through IConventionSetPlugin, throws for a collation on a StringSet or StringSet<T> column other than C, POSIX, ucs_basic, pg_c_utf8 and default, which compare bytes; a name doesn't say whether a collation is deterministic. ValueSetSqlGuard refuses EF.Functions.Collate over a string set the same way. A JSON document holds the set's literal and is not checked. Found-By: CA Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…migration and changelog (#483) The model-build rejection and the Collate refusal in the previous commit, in the EF guide's value set section, the v10.x migration list and its section, the Breaking lines of 11.0.0-preview.1, claim E86, and the live test that a column collated "C" answers as memory does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 26, 2026
Closed
Closed
# Conflicts: # test/oracles/claims.json
CaffeinatedCoder
deleted the
fix/483-reject-nondeterministic-string-set-collation
branch
October 26, 2026 13:31
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 #483
Problem
PostgreSQL compares the elements of a
text[]column with the column's collation, and memory compares them ordinally. Under a nondeterministic (case- or accent-insensitive) collation,Aequalsa. On aStringSetcolumn withUseCollation("case_insensitive")holding{A}, reproduced with the 10.3.0 packages:Contains("a"),IsSubsetOf({a}),Overlaps({a})and== {a}all matched, where memory saysfalse;Select(p => p.Tags.Remove("a"))gave{};ExecuteUpdate(… Remove("a"))stored{}, deleting an element memory keeps.Change
The option decided on #483 (reject at model build), after measuring the other one:
COLLATE "C"in the operators. The GIN index carries the column's collation, so a collated operand turns every indexed@>into a sequential scan, on an ordinaryen_UScolumn too. The plans on PostgreSQL 16 and 18 are on the issue.StringSetCollationConvention(new,IModelFinalizingConvention, added throughIConventionSetPlugin, which is additive and replaces no service). Building the model throws for a collation on aStringSet/StringSet<T>column other thanC,POSIX,ucs_basic,pg_c_utf8anddefault. Those compare bytes; a name doesn't say whether a collation is deterministic. A string set inside a JSON document is skipped, since the document holds its literal. A compiled model is checked when it is generated.ValueSetSqlGuardrefusesEF.Functions.Collateover a string set with any other collation, on the final SQL tree, so a predicate, an equality, a projection and anExecuteUpdatesetter are all covered.### Breakingin 11.0.0-preview.1. The 10.x port adds## Changed answers in 10.4.0.It changes answers, so labelled
silent: on 10.x it ships as the 10.4.0 minor under### Changed answers.Tests
StringSetCollationTests(no database). A nondeterministic collation is rejected onStringSetandStringSet<T>, with a message naming the property. The five byte-order collations map withCOLLATE. A JSON document isn't checked.EF.Functions.Collateis refused in a filter, an equality and a projection, and allowed with"C".StringSetCollationIntegrationTests(new). A column collated"C"answersContains,Overlaps,RemoveandExecuteUpdatewithRemoveas memory does.Collatetest fails.🤖 Generated with Claude Code