NaturalKey on self-aggregating aggregates (closes #4277)#4279
Merged
jeremydmiller merged 1 commit intomasterfrom Apr 22, 2026
Merged
NaturalKey on self-aggregating aggregates (closes #4277)#4279jeremydmiller merged 1 commit intomasterfrom
jeremydmiller merged 1 commit intomasterfrom
Conversation
Adds an end-to-end test to Bug_4197_fetch_for_writing_natural_key.cs matching the exact shape from #4277: a self-aggregating record with a static [NaturalKeySource] factory method. Before the fix in JasperFx.Events 1.29.1 this scenario silently failed — the natural-key lookup row was never written and FetchForWriting<TDoc, TKey>(key) returned a null aggregate. Bumps JasperFx.Events to 1.29.1 to pick up the fix. Companion: JasperFx/jasperfx#187 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
521a80d to
5e4d420
Compare
This was referenced Apr 23, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4277.
Summary
Adds an end-to-end regression test to `Bug_4197_fetch_for_writing_natural_key.cs` matching the exact self-aggregating shape from the issue:
```csharp
public sealed record Bug4277SelfAggregate(Guid Id, [property: NaturalKey] Bug4197AggregateKey Key)
{
[NaturalKeySource]
public static Bug4277SelfAggregate Create(Bug4197AggregateCreatedEvent e)
=> new(e.Id, new Bug4197AggregateKey(e.Key));
}
```
Before the fix, calling `FetchForWriting<Bug4277SelfAggregate, Bug4197AggregateKey>(key)` returned a null aggregate because the natural-key lookup row was never written — the discovery scan in JasperFx.Events silently skipped the static `Create` method on the aggregate type.
Upstream fix
Companion PR: JasperFx/jasperfx#187, shipping as JasperFx.Events 1.29.1. That PR:
Dependency
This PR bumps `Directory.Packages.props` `JasperFx.Events` from `1.29.0` to `1.29.1`. CI on this branch will fail with `NU1102` until `JasperFx.Events 1.29.1` is published to NuGet.org via the upstream PR. Local verification performed against a packed dev build of `1.29.1`:
🤖 Generated with Claude Code