Skip to content

docs: typed filters over Trim/Substring are re-created; concurrent TPC copies apply (#170, #171) - #173

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
docs/170-171-upgrade-notes
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
docs/170-171-upgrade-notes

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #170
Closes #171

Problem

#170. #72 changed how Trim, TrimStart, TrimEnd and Substring render in the typed translator, which also serves typed filters on indexes and exclusion constraints. The ### Changed answers row (root and PostgreSQL changelogs, i.e. the 5.5.0 release notes) and the upgrade entry named typed expression indexes only. A typed filter is stored as rendered SQL, so a 5.4.1 snapshot holds the old text and the first migrations add re-creates it. A Trim filter also covers other rows now.

#171. The TPC entry in docs/upgrading.md said a failing migration applies nothing. Copies of an index declared with IsCreatedConcurrently() run outside the transaction.

Change

  • CHANGELOG.md, src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md: the Typed expression indexes render Substring and Trim differently from EF Core's queries, so no query uses them #72 row names typed filters and says a typed filter can cover other rows (x.Code.Trim() != "" leaves out a tabs-only value). 59 and 57 words.
  • docs/upgrading.md, "Substring and Trim render as EF Core's queries" (heading and anchor kept):
    • names typed filters on indexes and exclusion constraints;
    • adds the TrimStart/TrimEnd rows to the table;
    • says which rows join or leave a trimmed filter, and that Substring filters cover the same rows;
    • says what the first migrations add re-creates, and what to clean up first (23505, 23P01), with a query that finds rows a filter now covers.
  • docs/upgrading.md, "Declarations on a TPC type…": with IsCreatedConcurrently(), earlier operations stay applied, an invalid index stays behind and the migration isn't recorded, so a re-run fails (42P07). Then how to recover: a pg_index query and DROP INDEX CONCURRENTLY.
  • DocumentationApiTests: TrimStart/TrimEnd added to the BCL allowlist, since the table now calls them.

Tests

The upgrade was measured on a real v5.4.1 snapshot. I wrote it from a v5.4.1 worktree with EF's snapshot generator, compiled it with Roslyn on this branch and diffed it against the live model through the Npgsql differ. The model has typed filters over each method on HasComplexIndex (unique and not), HasComplexCompositeIndex, HasExpressionIndex and HasExclusionConstraint, plus a ToLower filter as a control. The first migrations add gave 21 operations:

  • CREATE EXTENSION IF NOT EXISTS btree_gist;
  • drop and re-create of both exclusion constraints (btrim(…), substr(…, 1, 2) → substring(…, 1, 2));
  • drop and re-create of all 8 indexes: btrim/ltrim/rtrim(…, E' \t\n\r'), substring with two arguments, one argument and a column start;
  • the ToLower control was not touched, and the second diff is empty.

On PostgreSQL 18 (psql):

  • btrim(v) <> '' covers E'\t' and btrim(v, E' \t\n\r') <> '' doesn't;
  • = 'abc' takes in E'abc\t' only under the new trim, and the guide's query returns exactly that row;
  • substr and substring agree for starts of 0, negative and 1 argument;
  • a failed CREATE UNIQUE INDEX CONCURRENTLY leaves an invalid index that the guide's pg_index query lists, re-creating it fails with "already exists", and DROP INDEX CONCURRENTLY clears it.

The EF side of #171 wasn't run live: the migrator commits before a TransactionSuppressed command, and the history row comes last. That is documented EF Core behaviour.

The unit suite passed (631). The typed-filter rendering of Trim is already pinned against EF's ToQueryString() by TranslatorParitySweepTests, which renders filters through Where.

🤖 Generated with Claude Code

…pies apply (#170, #171)

The #72 Changed answers row (root and PostgreSQL changelogs) and its upgrade entry named typed
expression indexes only. Typed filters on indexes and exclusion constraints use the same
translator, are re-created by the first migrations add after 5.4.1, and a Trim filter covers
other rows now. Measured from a real v5.4.1 snapshot: every typed filter over Trim, TrimStart,
TrimEnd and Substring is dropped and re-created, a ToLower filter is not, the second diff is empty.

The TPC entry said nothing of a failing migration is applied. Copies of an index declared with
IsCreatedConcurrently() run outside the transaction, so earlier operations stay applied and an
invalid index is left behind; the entry now says how to recover.

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 documentation Improvements or additions to documentation package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL area/indexes Complex-property, composite, unique and filtered indexes area/expression-indexes Expression, typed LINQ and JSON member 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
@CaffeinatedCoder
CaffeinatedCoder merged commit 490b4de into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the docs/170-171-upgrade-notes branch October 20, 2026 13:51
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/expression-indexes Expression, typed LINQ and JSON member indexes area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring documentation Improvements or additions to documentation package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL

Projects

None yet

1 participant