Skip to content

feat: a declaration on a TPC type lands on every table of the hierarchy - #188

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/187-landings
Nov 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/187-landings

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #187

The first of three slices of #118 (decided 2026-11-25).

Problem

A declaration was resolved against the one table of the entity type it is written on. On a TPC type whose derived types have tables it was refused (#101), and on an abstract TPC root it was refused as not mapped to a table. EF Core gives an index declared there to every table of the hierarchy, and 5.x gave each table its copy.

Change

  • Landings.Of(entityType) in the kernel: the type's own table, and under TPC the table of every type derived from it that has one. The planner resolves the declaration once per table, on both sides of a diff; the refusal of A declaration on a concrete TPC root reaches the root's table only: the derived tables get no constraint, in silence #101 is gone, and an abstract TPC root lands on its derived types' tables.
  • A copy's name is made by the resolver's Name: a default name has its table in it; a stated name stays in the declaring type's own table and is {name}_{table} in a derived type's when the object's claims hold a NameClaim.Relation, and the name itself otherwise. The planner resolves a copy once to read its claims and again for the name.
  • The stored form and the contributor contract are unchanged.
  • A copy follows the rename of its own table: it is resolved again in that table, and what is left is a rename of the object.
  • On PostgreSQL 16 and 18 a constraint declared on the root of a TPC hierarchy is in all three tables, each refuses its own overlapping rows under its own constraint's name, and the catalog is what EnsureCreated() builds (On_the_root_of_TPC_each_table_refuses_its_own_overlapping_rows).

Found on the way:

  • A contributor that names an object without the resolver's Name gives every copy one name. That is refused as SK1001, not created twice (A_name_made_without_the_resolver_is_one_name_for_every_copy_and_is_refused). The kernel's sample contributor did so, and now sends a stated name through the resolver.
  • On EF Core 11 a complex property's column is in a TPC derived table too (the relational model of the scratch project; 5.x found the opposite on EF Core 10). So no path of a declaration is known to lack its column in a copy's table; the resolver's refusal of one that does stays.
  • No constraint holds across the tables: an overlapping stay and hold of one room are both taken. The README says so.

Deviation from the proposal on #118: a copy is resolved against the declaring entity type with the copy's table, not against the table's own entity type. The declaring type's property answers the column for every table of the hierarchy (measured), and the paths are the declaring type's.

Tests

Offline: 757 (kernel), 195 (PostgreSQL package), 87 (second provider). Live: 4 and 74 on PostgreSQL 16 and on 18, 86 on SQL Server 2022. The consumer smoke test: 47 rows.

Nine rules were changed in turn and a test failed for each:

Changed Fails
A TPC type has its own table alone 9 of the kernel's, A_constraint_on_a_type_of_TPC_is_in_every_table_of_the_hierarchy_below_it, the live test
Every hierarchy is treated as TPC The_landings_of_a_type_are_the_same_on_a_model_and_on_its_snapshot, A_snapshot_that_holds_one_is_read_and_moving_it_to_the_base_type_costs_nothing, A_constraint_on_a_derived_type_that_shares_its_table_is_refused
A derived type's table is no copy 7 of the kernel's, both of the PostgreSQL package's
The own table is a copy too 39 of the kernel's, 68 of the PostgreSQL package's
Every copy's name gets the table, whatever it claims A_name_that_is_taken_within_its_table_is_every_copys_name
No copy's name gets the table 7 of the kernel's, both of the PostgreSQL package's
Under a rename a copy is resolved in the declaring type's table A_copy_follows_the_rename_of_its_table
Under a rename a copy loses its suffix the same
A type without a table is passed over A_declaration_on_a_type_without_a_table_is_refused, added after the first run showed nothing held it

Not here: the 5.x reader and its fixture (slice 2), entity splitting and the TPT refusal (slice 3), the path of #85.

🤖 Generated with Claude Code

Landings.Of says which tables a declaration lands on: the type's own, and
under TPC the table of every type derived from it that has one. The
planner resolves the declaration once per table, on both sides of a diff,
so nothing of the copies is stored. The refusal of #101 goes, and a TPC
root without a table lands on its derived types' tables.

A copy's name is made by the resolver's Name. A default name has its
table in it. A stated name stays in the declaring type's own table and
is {name}_{table} in a derived type's when the object claims a name of
the schema, and the name itself otherwise, as 5.x named its copies.

A copy follows the rename of its own table. A contributor that names an
object without the resolver gives every copy one name, which is refused
as SK1001.

Closes #187

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 25, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit c7cb78f into main Nov 25, 2026
10 of 11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/187-landings branch November 25, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Landing function, slice 1: a declaration on a TPC type lands on every table of the hierarchy below it

1 participant