Skip to content

Tests: catch the seeded core and SQL Server differ defects; render SQL Server SQL with the model - #113

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
tests/96-sqlserver-seeds
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
tests/96-sqlserver-seeds

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #96

Stacked on #107 (#92) → #105 (#90) → #103 (#91). Merge in that order. The .NET workflow runs only on PRs into main/release/**, so this branch's CI is a workflow_dispatch run on the same commit.

Problem

The 5.5.0 core and SQL Server analysis seeded defects, and the whole suite passed with each one applied:

  • Descending removed from ResolvedIndexPart equality: changing x.A to DbOrder.Desc(x.A) produced no migration (silent).
  • FillFactor, or Clustered and SortInTempDb, removed from the SQL Server whitelist: property-level declarations lost them, since every SQL Server differ test was entity-level and BuilderApiParityTests checked only whitelist → builder.
  • TransformIndexAnnotation skipped on the property-level path: INCLUDE paths stayed unresolved.
  • CanRenameIndexes => false on SQL Server.
  • The native-clustered-index branch of the clustered-slot check.
  • A uniqueness-only, filter-only or provider-option-only change, each caught by one incidental test.
  • No SQL Server snapshot round trip.

And a harness trap: MigrationHarness.SqlServerSql rendered with model: null, which makes EF's SQL Server generator add its pre-2.0 IS NOT NULL filter to every unique index over nullable columns (UseLegacyIndexFilters). database update never adds it, and that is what hid #88.

Change

Test-only; no changelog line.

  • MigrationHarness.SqlServerSql(operations, target) takes the target model and renders with it. SqlServerDifferTests' private generator delegates to it, and every caller passes its model.
  • IndexChangeDetectionTests (new): a direction-only, uniqueness-only, filter-only and provider-option-only change each drops and re-creates the index, and an unchanged index produces nothing.
  • SqlServerDifferTests: a property-level test with all six options and INCLUDE property paths, asserting the forwarded annotations and the rendered DDL, and a name-only change rendering sp_rename.
  • BuilderApiParityTests: every option a satellite's builder sets is forwarded by its differ, for both satellites. It calls IsForwardedIndexAnnotation on a real differ. KeysSetBy comes from Core: refuse a satellite's index options instead of dropping them #107.
  • SqlServerNullableUniqueTests: a filterless unique index over nullable columns renders without a filter. With model: null it gains the legacy one.
  • SnapshotRoundTripTests: the generate-compile-rebuild helper takes the provider. A SQL Server round trip covers every option property- and entity-level, a DESC part and a placeholder filter. It asserts four creates from nothing, so an empty diff is not vacuous.

Tests

Each seed applied on its own, full unit suite, sources restored after each (git status clean):

Seed Fails
Descending out of ResolvedIndexPart equality and hash direction-only change
FillFactor out of the SQL Server whitelist builder → whitelist parity, property-level options, plus every SQL Server FillFactor test (with #92 the differ refuses an option it does not forward)
Clustered and SortInTempDb out of the whitelist parity, property-level options, all clustered tests
property-level TransformIndexAnnotation skipped property-level options (INCLUDE Name/Contact.Email unresolved)
CanRenameIndexes => false sp_rename test
native-clustered branch disabled the clustered-native-index test from #105
IsUnique out of IndexDescriptor equality and hash uniqueness-only change (+2 incidental)
Filter out of equality and hash filter-only change (+3 incidental)
provider annotations out of equality and hash provider-option-only change (+3 incidental)
harness back to model: null the filterless-render test

Full unit suite: 426 passed.

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code stacked Base is another open PR; merge in order, CI does not run until it targets main package/core Affects EFCore.ComplexIndexes package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/indexes Complex-property, composite, unique and filtered indexes labels Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder force-pushed the tests/96-sqlserver-seeds branch from f8eab8a to 981c13b Compare October 20, 2026 06:09
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/92-core-refuses-satellite-options branch from 98ea257 to 319ddbd Compare October 20, 2026 06:09
… Server SQL with the model (#96)

The 5.5.0 analysis seeded defects the suite did not notice; each now fails
a test written for it:

- Descending dropped from ResolvedIndexPart equality: a direction-only
  change produced no migration. IndexChangeDetectionTests re-creates the
  index on a direction-only, uniqueness-only, filter-only and
  provider-option-only change, each seeded out of IndexDescriptor equality.
- FillFactor, or Clustered and SortInTempDb, removed from the SQL Server
  whitelist; TransformIndexAnnotation skipped on the property-level path:
  every SQL Server test was entity-level. A property-level test covers all
  six options and INCLUDE path resolution, and BuilderApiParityTests now
  also checks that every option a builder sets is forwarded (both
  satellites).
- CanRenameIndexes => false on SQL Server: a name-only change renders
  sp_rename.
- The native-clustered-index branch: covered by #90's test, proven here.
- A SQL Server snapshot round trip: six options property- and entity-level,
  a DESC part and a placeholder filter, without churn.

MigrationHarness.SqlServerSql takes the target model and renders with it,
as database update does. With model: null, SQL Server's generator added its
pre-2.0 IS NOT NULL filter to unique indexes over nullable columns, which hid
#88; a test renders a filterless index and fails with model: null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/92-core-refuses-satellite-options branch from 319ddbd to 0c27caa Compare October 20, 2026 06:26
@CaffeinatedCoder
CaffeinatedCoder force-pushed the tests/96-sqlserver-seeds branch from 981c13b to 01c1a52 Compare October 20, 2026 06:26
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from fix/92-core-refuses-satellite-options to main October 20, 2026 06:37
@CaffeinatedCoder
CaffeinatedCoder merged commit 25a83c4 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the tests/96-sqlserver-seeds branch October 20, 2026 06:40
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 package/core Affects EFCore.ComplexIndexes package/sqlserver Affects EFCore.ComplexIndexes.SqlServer stacked Base is another open PR; merge in order, CI does not run until it targets main tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: seeded defects in the core and SQL Server differs that the suite does not catch, and the model-less SQL Server rendering

1 participant