Skip to content

fix(postgresql): fold a captured Substring start as EF Core does - #124

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/117-substring-captured-start
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/117-substring-captured-start

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #117

Stacked on #123 (#94) → #122 (#80) → #121 (#101); merge those first.

Problem

A typed expression index or filter whose Substring start is a captured variable rendered substring("Code", (1 + 1)); EF Core's query for the same lambda writes substring("Code", 2). PostgreSQL folds the constant before it matches an index to a query (the live sweep confirms the index serves EF Core's query), so no answer changed, but the rendering disagreed with EF Core's for no reason.

Change

Tests

  • NpgsqlLinqExpressionIndexTests.Substring_start_is_folded.
  • With the change reverted, that test fails and the parity sweep fails 20 rows.
  • Full suite 424/424 including the PostgreSQL integration suite.

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working stacked Base is another open PR; merge in order, CI does not run until it targets main severity/low Cosmetic, message or documentation-level difference package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL area/expression-indexes Expression, typed LINQ and JSON member indexes labels Oct 20, 2026
x.Code.Substring(start) with a captured int start rendered
substring("Code", (1 + 1)) where EF Core writes substring("Code", 2).
PostgreSQL folds the constant before it matches an index to a query, so
no answer changed; the rendering disagreed for no reason. A start known
at the declaration, literal or captured, is now folded. The templates it
changes are the ones #72 already re-creates in 5.5.0.

Verified with the change reverted: the new test fails and the parity
sweep fails the 20 rows this removes from waivers.txt. The four left
there are nullable != filters, shaped as #118 describes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/117-substring-captured-start branch from 9f23cec to 8f592d5 Compare October 20, 2026 06:35
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from fix/94-concat-coalesce to main October 20, 2026 07:05
@CaffeinatedCoder
CaffeinatedCoder merged commit 51ef260 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/117-substring-captured-start branch October 20, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/expression-indexes Expression, typed LINQ and JSON member indexes bug Something isn't working package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL severity/low Cosmetic, message or documentation-level difference stacked Base is another open PR; merge in order, CI does not run until it targets main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typed expression indexes: a captured Substring start renders unfolded, where EF Core folds it

1 participant