Repository navigation
feat: the resolver's first slice, paths and templates to columns and SQL, alike on a model and on its snapshot - #59
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58
The first slice of #43, which stays open.
Problem
SchemaResolverwas a shell withTable,DialectandSql; the only implementation was the tests' stand-in. A contributor'sResolvecould 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)andName(declared, prefix, parts).SqlFragment.Dependencies: what the SQL reads.SchemaSql.FragmentandSchemaSql.Listcarry it through composition.SqlFragmentstill compares by its text alone, now by an explicitEquals.Internal, in
Resolution/Internal:ModelSchemaResolver. It reads metadata only, which is what a model and a snapshot share.StoreObjectIdentifier; complex properties are walked, soHasColumnNameinside one is honoured.Email.Valueis the column ofEmailwhen a converter stores the type ofValue. On a snapshot (property bag, no converter) an indexer property is taken as it is.{Path}outside single-quoted literals, and only when its content is a property path.{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 compilerSnapshotRoundTripTestshad, 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/Predicateas declaration values.Two rules are ported from 5.x with their known limits, to decide before epoch 1 is frozen by a release:
Email.Alias, also astring) would resolve to the column too.{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.
SchemaResolverTestsasks 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 keepsEmailas an indexer property of typestringwith no converter.Each rule undone in a scratch copy:
Email.LengthCreatedAt.Year,Name.LengthA_template_without_a_placeholder_depends_on_the_whole_tablePrefs.ThemeA_fragment_composed_of_others_reads_what_they_readFragments_compare_by_their_text_alone🤖 Generated with Claude Code