Skip to content

fix: two legacy readers for one annotation are refused - #148

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
fix/one-reader-per-annotation
Nov 16, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
fix/one-reader-per-annotation

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #108

Problem

AddLegacyDeclarationReader<TReader>() keeps one registration per class, so two classes that read the same annotation are both kept, and the planner asks every reader. Each reads the object out of the snapshot. One copy pairs with the model's declaration; the other is left over where the diff starts.

Run on main (the issue had it from reading): with a second reader class for the annotation of the kernel tests' OldGuardReader, the diff from the snapshot in the old format to the model that declares the same object is

DROP INDEX ux_animal;

and the diff after it is empty. The migration drops an object the model still declares, and nothing reports it afterwards.

Nothing registers two readers for one annotation today. It takes two packages that both take over from one earlier package, or one package with two classes.

Change

  • SchemaOperationPlanner: where the readers are first asked for, two with one annotation are refused, naming the annotation and both classes (SchemaKitStrings.TwoReadersForOneAnnotation). It is refused whatever the models hold, as two contributors for one owner are.
  • It is the planner's and not AddLegacyDeclarationReader's: Annotation is an instance member, so a reader says it only once it is made.
  • CLAUDE.md: the rule, beside the reader's.

Tests

  • LegacyDeclarationReaderTests.Two_readers_of_one_annotation_are_refused: the pair above, refused with both class names in the message.
  • Two_readers_of_one_annotation_are_refused_where_no_model_holds_it: the same registration with models that carry no annotation.
  • Both fail with the check taken out (in a scratch copy: the first finds no exception where main writes the DROP).
  • On this branch: the kernel's 656 tests and the PostgreSQL package's 166 that need no server pass. The package's own reader is the only one for CustomExclusion:Constraints, so nothing of it changes.

🤖 Generated with Claude Code

AddLegacyDeclarationReader keeps one registration per class, so two classes that read the
same annotation were both asked. Each read the object out of the snapshot; one copy paired
with the model's declaration, and the other was dropped by the migration while the model
still declared it. The diff after that was empty.

The planner now refuses the pair where it first asks for the readers, naming the annotation
and both classes. It is the planner's and not the registration's, since a reader says its
annotation only once it is made.

Closes #108

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 16, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing; the fix ships as a minor, never a patch package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/low Cosmetic, message or documentation-level difference area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 16, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit cfd4e48 into main Nov 16, 2026
10 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/one-reader-per-annotation branch November 16, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring bug Something isn't working package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing; the fix ships as a minor, never a patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two legacy readers for one annotation read an object twice, and the migration drops what the model still declares

1 participant