Skip to content

Refuse the satellites' constraints and null filter in the core differ (#150) - #162

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
claude/150-core-refuses-constraints-fcb460
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
claude/150-core-refuses-constraints-fcb460

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #150

Problem

#92 made the core differ refuse a satellite's index options and stopped there. With UseComplexIndexes() in place of UseNpgsqlComplexIndexes() or UseSqlServerComplexIndexes(), or with dotnet ef running without the satellite's .targets, the core differ still dropped:

EnsureCreated() applied the rest cleanly. Measured with the fix reverted: on PostgreSQL 18 the table and the complex index were created and the constraint was not. On SQL Server 2022 ux_vin had no filter, and the second row without a VIN was refused with 2601.

Change

Tests

  • CoreDifferSatelliteDeclarationTests (22 tests):
    • the core differ refuses each constraint kind on Npgsql, and a nullable unique index on SQL Server
    • GenerateCreateScript() refuses under UseComplexIndexes() on both providers
    • the satellite registrations and differs still render the constraints and the filter
    • SQLite ignores these declarations, and so does SQL Server for PostgreSQL's constraints
    • source models are not checked
    • the annotation names match the satellite's constants
    • only the satellite differs report IsSatelliteDiffer
  • PostgresIntegrationTests.Core_registration_refuses_satellite_constraints, one row per kind on PostgreSQL 18: EnsureCreated() refuses before creating any table, and the satellite registration creates the constraint.
  • SqlServerIntegrationTests.Core_registration_refuses_a_unique_index_over_nullable_columns, on SQL Server 2022.

Each part of the fix was reverted to check that its tests fail:

Reverted Fails
constraint loop 3 unit refusal rows and the PostgreSQL runtime test. PostgreSQL 18 integration, all 3 rows: "EnsureCreated() applied cleanly under UseComplexIndexes(), with 0 of the declared constraint and 1 complex index"
null-filter loop 2 SQL Server unit tests. SQL Server 2022 CI lane, from a dispatched run on a throwaway proof/150-revert branch: "ux_vin has filter none, and a second row without a VIN was refused it with 2601". The same lane passed on proof/150-fix. Both branches are deleted.
IsSatelliteDiffer gate the satellite differ and registration tests (the satellites refuse their own constraints)
source checked too the snapshot tests, including #92's
an annotation renamed the constants test

Local: 648 tests pass, excluding the SQL Server category. That includes PostgreSQL 18 and 16 integration.

🤖 Generated with Claude Code

…#150)

satellite's provider and stopped there. With UseComplexIndexes() in place
of UseNpgsqlComplexIndexes() or UseSqlServerComplexIndexes(), or without
the satellite's .targets at design time, the core differ still dropped
the PostgreSQL satellite's exclusion constraints, temporal constraints
and temporal foreign keys, and the SQL Server satellite's IS NOT NULL
filter on a unique index over nullable columns (#88). EnsureCreated()
applied the rest cleanly: on PostgreSQL 18 the table and the complex
index existed and the constraint did not.

all three kinds in one place. It runs when a satellite serves the
provider and the running differ is not that satellite's: the satellites
override an internal IsSatelliteDiffer, so a consumer's subclass of a
satellite differ keeps working. The constraint annotations sit in the
Satellites table beside the options, held to the satellites' constants by
a test; the null filter mirrors SqlServer's ImplicitFilter (unique, no
filter, nullable key column, rendering version 3). #134's check stays
separate: it runs where no satellite exists and has another remedy.
Target model only, so a snapshot holding such declarations still diffs.

Verified by reverting each part: without the constraint loop the unit
refusals and the PostgreSQL 18 integration rows fail, the latter with
"EnsureCreated() applied cleanly under UseComplexIndexes(), with 0 of the
declared constraint and 1 complex index"; without the filter loop the SQL
Server unit refusals fail; without the IsSatelliteDiffer gate the
satellites refuse their own constraints; validating the source as well
fails the snapshot tests; a renamed annotation fails the constants test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working breaking Changes an answer or a signature — needs a major silent Answers wrongly without throwing — fixes go in the next major, never deferred severity/high Wrong results, crash or failed writes in a realistic scenario package/core Affects EFCore.ComplexIndexes package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/indexes Complex-property, composite, unique and filtered indexes area/constraints Temporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraints area/migrations The differs, snapshot format, EnsureCreated and design-time wiring labels Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/constraints Temporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraints area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring breaking Changes an answer or a signature — needs a major bug Something isn't working package/core Affects EFCore.ComplexIndexes package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL package/sqlserver Affects EFCore.ComplexIndexes.SqlServer severity/high Wrong results, crash or failed writes in a realistic scenario silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UseComplexIndexes() on PostgreSQL or SQL Server still drops exclusion and temporal constraints and the IS NOT NULL filter without a word

1 participant