Skip to content

feat!: SQL in a declaration is stored as segments, format v 3 - #182

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/178-segments
Nov 24, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/178-segments

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #178

Problem

A lambda's SQL was stored as one string with {Path} placeholders, and the resolver found the columns by scanning that string at every diff. A brace in a quoted identifier or a dollar-quoted string was taken for a placeholder, a template that mixed {A} with a column written by hand recorded A alone, and Predicate.And searched SQL text for a conjunct (#83). #114 decided the stored form on 2026-11-24: segments. This is its first slice; the translator still runs at the call.

Change

  • SqlTemplate, a value of segments: SqlSegment.Text (text a package wrote, which names no column), Column (a property path) and Raw (SQL written by hand). Stored as a list: ["lower(",{"col":"Email.Value"},") = 'a'"], {"raw":…} for the third. The template is unmarked and shows no SQL string; what makes one and its Segments are the contract's.
  • The resolver reads segments and scans nothing. Hand-written SQL reads the whole table beside the columns it names by a path; a package's own text reads nothing.
  • Predicate and KeyTarget.Template hold a SqlTemplate and are not made from a string. Predicate.And composes segments.
  • PgExclusion stores sql and where as segments. The 5.x reader reads an expression and a filter as SQL written by hand.
  • v is 3. A v of 2 is refused with a message that says to scaffold again (SchemaKit: snapshot format v2 and CodoMetis: annotation keys ship in 11.0.0; the 5.x format is read forever (D11) #9).
  • 11.0.0-preview.2, with its changelog section, which also has the line of Npgsql EF 11.0.0 is out: the floors move from rc.3 to [11.0.0, 12.0.0) #174.

Not as #178 was written, and recorded there:

  1. The default name's rule is unchanged. The rule as proposed would rename lowerfirstname to lowerfirst_name at the handover from 5.x.
  2. Predicate and KeyTarget.Template have their new public shape already, which Binder, slice 2: a declaration is held unbound until the model is finalized, then bound and checked #179 lists.
  3. {Path} is still looked for once, where a package's text or a 5.x filter becomes segments. Nothing stored is scanned.

Tests

Measured on 2026-11-24:

  • Offline: 744 of the kernel's, 183 of the PostgreSQL package's, 85 of the second provider's, 127 probes.
  • Live: 4 and 73 on PostgreSQL 16 and on 18, the handover from 5.x among them; 86 on SQL Server 2022; the consumer smoke test's 47 rows on PostgreSQL 18, packed as 11.0.0-preview.2.
  • New: the stored form of a template verbatim and 14 shapes that are refused; a template is its segments; hand-written SQL depends on the whole table; hand-written SQL that reads like a conjunct is none; a 5.x filter that names a column outside a placeholder has the constraint rebuilt around a dropped column.

Each rule removed in turn, with the test that failed:

Removed Fails
Hand-written SQL reads the whole table Sql_written_by_hand_depends_on_the_whole_table, the rename test
A 5.x filter is read as hand-written A_filter_of_5x_may_read_a_column_it_does_not_name_by_a_path
Hand-written SQL is told from And's text Hand_written_sql_that_reads_like_a_conjunct_is_none
The one-group rule of And 4 rows of Only_a_conjunct_And_itself_wrote_is_taken_for_one
Neighbouring text is one segment 2 tests
An unknown segment is refused 3 rows of A_template_in_another_shape_is_refused
A v of 2 is refused the row of A_format_version_this_version_does_not_know_is_refused

🤖 Generated with Claude Code

The first slice of #114. A lambda's SQL was one string with {Path}
placeholders, which the resolver scanned at every diff. It is a
SqlTemplate now: text a package wrote, a column by its property path, and
SQL written by hand, stored as a list in which a string is package text,
{"col":…} a column and {"raw":…} hand-written SQL.

- The resolver reads segments and scans nothing. Hand-written SQL reads
  the whole table beside the columns it names by a path; a package's own
  text reads nothing.
- Predicate and KeyTarget.Template hold a SqlTemplate and are not made
  from a string. Predicate.And composes segments, and hand-written SQL
  that reads like its text is not taken for a conjunct.
- PgExclusion stores sql and where as segments. An expression and a
  filter of a 5.x snapshot are read as SQL written by hand.
- v is 3. A v of 2, 11.0.0-preview.1's, is refused with a message that
  says to scaffold again.
- The version is 11.0.0-preview.2, with its changelog section.

The default name's rule is unchanged: it is built from the segments by
the same letters and digits as before, so that an object 5.x named keeps
its name at the handover.

Closes #178

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 24, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request breaking Changes an answer or a signature package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL area/expression-indexes Expression, typed lambda and JSON member indexes labels Nov 24, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 288b0c8 into main Nov 24, 2026
11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/178-segments branch November 24, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/expression-indexes Expression, typed lambda and JSON member indexes breaking Changes an answer or a signature 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.

Binder, slice 1: templates stored as segments, format v 3, and a resolver that scans nothing

1 participant