Skip to content

feat: the resolver's first slice, paths and templates to columns and SQL, alike on a model and on its snapshot - #59

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/resolver-first-slice
Nov 12, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/resolver-first-slice

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #58

The first slice of #43, which stays open.

Problem

SchemaResolver was a shell with Table, Dialect and Sql; the only implementation was the tests' stand-in. A contributor's Resolve could not turn a path or a template into SQL, so no real contributor could be written.

Change

Public, under SK9001:

  • SchemaResolver.Column(path), Template(sql) and Name(declared, prefix, parts).
  • SqlFragment.Dependencies: what the SQL reads. SchemaSql.Fragment and SchemaSql.List carry it through composition. SqlFragment still compares by its text alone, now by an explicit Equals.

Internal, in Resolution/Internal:

  • ModelSchemaResolver. It reads metadata only, which is what a model and a snapshot share.
    • The column is asked of the declared property with the table's StoreObjectIdentifier; complex properties are walked, so HasColumnName inside one is honoured.
    • Email.Value is the column of Email when a converter stores the type of Value. On a snapshot (property bag, no converter) an indexer property is taken as it is.
    • A placeholder is {Path} outside single-quoted literals, and only when its content is a property path.
    • SQL without a placeholder depends on the whole table (plan, 3.7).
    • A default name is {prefix}_{table}_{tokens}; a token is a column's name or a template's letters and digits, never the rendered SQL.
  • SchemaResolverFactory, a diff-time service. It refuses a declaration of an epoch other than 1 and one on a type mapped to no table.
  • Harness/Snapshots.cs: the snapshot compiler SnapshotRoundTripTests had, now shared.

Not here

Each is listed in #58 and stays in #43: JSON members (a path into a JSON-mapped complex type is refused), renamed tables and columns, the tables of a TPC declaration, the golden corpus (#33), and KeyTarget/Predicate as declaration values.

Two rules are ported from 5.x with their known limits, to decide before epoch 1 is frozen by a release:

  • The converter-member check compares types only. A second member of the stored type (Email.Alias, also a string) would resolve to the column too.
  • Only single quotes are tracked in a template. A {Path} inside a double-quoted identifier, a dollar-quoted string or a comment is replaced.

Tests

Kernel tests without a server, on SDK 11.0.100 in the checkout: 291 before, 326 after. Probes: 125 pass. The PostgreSQL integration tests did not run locally; CI runs them.

SchemaResolverTests asks every rule of the configured model and of its snapshot (scaffolded by EF Core, compiled with Roslyn), on Npgsql, SQL Server and SQLite where the provider's delimiting matters. One test holds the premise of the property-bag rule: the snapshot keeps Email as an indexer property of type string with no converter.

Each rule undone in a scratch copy:

Undone Fails
The converter's type is not compared the row Email.Length
No property-bag rule the path, template and name tests (snapshot side), 9 rows
The property-bag rule for every type CreatedAt.Year, Name.Length
Placeholders inside literals too the template test, the whole-table test
Any brace pair is a placeholder the template test
No whole-table dependency A_template_without_a_placeholder_depends_on_the_whole_table
A column read twice is listed twice the template test (found a gap: it passed until the template read one column twice)
No epoch check both epoch rows
No JSON refusal the row Prefs.Theme
A column fragment records nothing the path test, the composition test
Default name from the SQL text both name tests
Composition drops dependencies A_fragment_composed_of_others_reads_what_they_read
A list drops dependencies the same
Fragments compare dependencies too Fragments_compare_by_their_text_alone

🤖 Generated with Claude Code

…SQL, alike on a model and on its snapshot

SchemaResolver gains Column, Template and Name. The kernel's implementation
reads metadata only, so a configured model and its compiled snapshot resolve
alike: the column is asked of the declared property, a member of a converted
property is its column when the converter stores the member's type, and on a
snapshot, which keeps no converter, an indexer property is taken as it is.

A placeholder is {Path} outside single-quoted literals. Every fragment
records what it reads, composition keeps it, and SQL without a placeholder
depends on the whole table. A default name is built from tokens kept apart
from the SQL. A declaration of an unknown resolution epoch is refused.

JSON members, renames and TPC stay in #43.

Closes #58

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 12, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 12, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 5fcc53b into main Nov 12, 2026
7 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/resolver-first-slice branch November 12, 2026 08:06
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SchemaResolver, first slice: property paths and templates to columns and SQL, alike on a model and on its compiled snapshot

1 participant