Skip to content

On SQL Server, match the columns an index reads without regard to case (#189) - #194

Merged
CaffeinatedCoder merged 4 commits into
release/5.xfrom
fix/189-case-insensitive-columns
Oct 23, 2026
Merged

CaffeinatedCoder merged 4 commits into
release/5.xfrom
fix/189-case-insensitive-columns

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #189

Into release/5.x. Closes acts only on main, so #189 is closed by hand after the merge.

Problem

On SQL Server, an unchanged complex index was moved out of the way of an ALTER COLUMN only when its filter or INCLUDE list spelled the column in exactly the column's case. SQL Server reads identifiers without regard to case under its default collation, so [note] IS NULL reads the column Note, and ValidateIncludedColumns accepts the INCLUDE entry note on purpose. ColumnsReadBy and ColumnsNamedIn compared ordinally, so they missed the dependency. The ALTER COLUMN then failed at apply (Msg 5074). The #182 check for a case-only rename (Note → NOTE) under such a filter missed it the same way.

Change

CustomMigrationsModelDiffer.ColumnsReadBy (now an instance method) and ColumnsNamedIn compare names under IndexNameComparer: case-insensitive on SQL Server and SQLite, ordinal on PostgreSQL. ColumnsNamedIn takes the comparer as an optional argument, so the PostgreSQL constraint checks keep their ordinal match unchanged. Ignoring case is the safe direction: at worst it costs a needless rebuild on a case-sensitive collation.

Also: a ### Fixed line in the root, core and SQL Server changelogs (the migration failed at apply, so no database holds its result), and CLAUDE.md.

Tests

🤖 Generated with Claude Code

…o case

SQL Server reads identifiers without regard to case under its default
collation, so a filter [note] IS NULL or an INCLUDE entry "note" reads
the column Note, and ValidateIncludedColumns accepts that spelling. The
check that moves an unchanged index out of the way of ALTER COLUMN (and,
since #182, of a rename of a column its filter reads) matched names
ordinally, missed the dependency, and the migration failed at apply.

ColumnsReadBy and ColumnsNamedIn now compare under IndexNameComparer:
case-insensitive on SQL Server and SQLite, ordinal on PostgreSQL, where
a quoted "note" is another column than "Note".

Closes #189

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.6.0 milestone Oct 23, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working severity/low Cosmetic, message or documentation-level difference package/core Affects EFCore.ComplexIndexes package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring labels Oct 23, 2026
CaffeinatedCoder and others added 3 commits October 23, 2026 11:22
…nsensitive-columns

# Conflicts:
#	CHANGELOG.md
#	CLAUDE.md
…me from

The merge of release/5.x committed conflict markers in CLAUDE.md. The
line itself was already damaged on release/5.x: two earlier conflict
resolutions appended a sentence after an anchor that the line continues
past, so its tail ("Because renames run after the base operations, a
pair stays a") appeared twice. Rebuilt with the #186, #187/#188 and #189
sentences once each and the tail once.

Refs #189

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring bug Something isn't working package/core Affects EFCore.ComplexIndexes package/sqlserver Affects EFCore.ComplexIndexes.SqlServer severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant