Skip to content

fix: an included member of a value object in a 5.x snapshot is read as its property's column - #273

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
claude/lucid-herschel-9bd113
Nov 29, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
claude/lucid-herschel-9bd113

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #263

Problem

A 5.x snapshot whose index includes a member of a value object was refused:

member.Property<string>("Email").IsRequired();
member.HasAnnotation("CustomIndex:CompositeIndexes",
    """[{"paths":["Kind"],"unique":false,"props":{"Npgsql:IndexInclude":["Email.Value"]}}]""");
The model snapshot holds the index 'Kind' of Member as EFCore.ComplexIndexes 5.x stored it, and the index
includes 'Email.Value', which is neither a property of Member nor the column of one. …

5.x resolved an entry of IncludeProperties(…) by the walk it had for a key (ResolveIncludeList → ResolveProperty → FindConvertedMember, read at v5.6.0), which goes one step past a converted property: the index in the database carries the column of Email. The same path as a key or in a filter was read already, through the resolver. The reader told an included path from a column's name with a walk of its own, which did not take that step.

The index of a property (CustomIndex:IsIndexed with Npgsql:IndexInclude beside it) had the same refusal: both readers build through ComplexIndexes5xIndexes.Build.

Change

  • ComplexIndexes5xIndexes.IncludedPath takes an entry one step past a property as a path where the declaring type is a property bag and the property an indexer property. That is the resolver's rule for a snapshot (PropertyPaths.Walk) and 5.x's own. The entry is handed on as it stands, and the resolver says which column it is, as for a key.
  • The reader keeps a walk of its own: a reader gets no resolver, and nothing in the kernel's public contract answers "is this a path" without one. Nothing under the kernel changed, and the resolver returns what it returned.
  • Still refused by name: a second step (Email.Value.Length), a step past a property that is not there, a step past a complex property (Address.Value), and a member on a type that has its CLR type.
  • CHANGELOG.md has the line under a new ### Fixed of preview.3; CLAUDE.md says the rule where it describes the index readers. The guide says nothing this makes false and is unchanged.

One answer changes for an input the reader took before: an entry that is one step past a snapshot's property and the literal name of another property's column (a column named Email.Value) is the path now, where it was that column. 5.x's snapshot side read it as the path from 5.3.0.

Read from 5.x's tags: before 5.1.0 an included entry was a column's name as written, and before 5.2.0 no walk went past a property, so Email.Value failed when the migration was applied. No version built such an index over another column than Email's, so the entry is read alike whatever the snapshot's rendering version.

Tests

No server is needed. dotnet test with --filter "TestCategory!=Integration": PostgreSQL 489 passed, kernel 897 passed.

New, each run with the reader as on main (source restored with a new timestamp and rebuilt):

Guard Without the fix
An_included_entry_one_step_past_a_snapshots_property_is_that_propertys_column (ComplexIndexes5xIndexReaderTests): the entry is read, the create has INCLUDE ("Email"), also below a complex property; four entries stay refused fails: "includes 'Email.Value', which is neither a property of Member nor the column of one"
An_included_member_declared_as_the_property_is_no_operations (LegacyValueObjectHandoverTests): the snapshot against include: [x => x.Email], Up and Down fails with the same refusal
An_included_member_on_an_index_of_a_property_is_the_property_too: the same for the marker on a property, with its drop and create fails with the same refusal, for the index 'Address.City'
What_is_declared_instead_creates_what_5x_declared, new row: dropped by IX_members_Kind, created as CREATE INDEX "IX_members_Kind" ON members ("Kind") INCLUDE ("Email"); fails with the same refusal
The_lambda_through_the_member_is_refused_and_the_refusal_says_what_to_write, new row: include: [x => x.Email.Value] in the model gets the resolver's refusal with what to write fails: the snapshot is refused first

What stays refused, each condition taken out in turn:

  • without i == segments.Length - 2, the reader's row fails: Email.Value.Length is read;
  • without the property bag and the indexer property together, the new row of What_an_index_declaration_cannot_say_is_refused_by_name fails: Email.Length on a type with its CLR type is read. Either alone still passes: a property bag's properties are indexer properties. Both are there because the resolver and 5.x state both.

The snapshot is written in the test in 5.x's form, not scaffolded by 5.x: no fixture has a value object. The Member of LegacyValueObjectHandoverTests gained a complex property Address.City, in the model and in the snapshot, since 5.x put its marker on a property of a complex type alone; the tests that were there pass unchanged.

migration-safety-review, sections 2 and 6: no stored form moves (a declaration read from a snapshot is never stored, and PgIndexDeclarationTests passes), the resolver is untouched so there is no new epoch, and the annotation is read in the same models as before.

🤖 Generated with Claude Code

CaffeinatedCoder and others added 2 commits November 29, 2026 11:12
…s its property's column

5.x resolved an entry of IncludeProperties by the walk it had for a key, which
goes one step past a converted property: "Email.Value" was the column of
Email. The readers of 5.x's indexes told a path from a column's name with a
walk that did not, and refused the snapshot. On a snapshot's property the
member is now taken as it is, as the resolver takes it there; the entry is
handed on as the path, and the resolver says which column it is.

Both readers build through ComplexIndexes5xIndexes.Build, so the index of an
entity type and the index of a property had the one refusal and have the one
fix.

Refs #263

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pshot is read

Refs #263

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 29, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL severity/medium Inconsistency or failure in a narrow scenario area/indexes Typed indexes: access methods, options, unique and filtered labels Nov 29, 2026
@CaffeinatedCoder

Copy link
Copy Markdown
Owner Author

Reviewed at 68de442 by the coordinating session.

  • Read: the reader's change is the one condition in Names, one step past a property of a property bag that is an indexer property, and the entry is handed on for the resolver to say the column. Nothing under the kernel changed, no stored form moves, and the resolver answers what it answered.
  • Run, in a copy of the head with ComplexIndexes5xIndexReader.cs as on main: the five tests the description names fail, each with the refusal "includes 'Email.Value', which is neither a property of Member nor the column of one" (5 failed, 39 passed of the two classes).
  • The one answer that changes for an input taken before, an entry that is one step past a snapshot's property and also the literal name of another column, is said in the description and is 5.x's own reading.
  • Merges cleanly into main at 0d7ac39 (after feat: the verifier compares an expression key and a condition through a shadow #269), also ahead of test: release.yml smoke-tests the packages it publishes, and a lane has the consumer on the newest EF Core #274.

Nothing to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/indexes Typed indexes: access methods, options, unique and filtered bug Something isn't working package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL severity/medium Inconsistency or failure in a narrow scenario

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A 5.x index that includes a member of a value object is refused in the snapshot

1 participant