Skip to content

Commit

Permalink
forcing pg to return the rows affected on an update stream version
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Jul 26, 2024
1 parent c3944b0 commit b01ee81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
using Marten.Storage;
using Marten.Testing.Harness;
using Xunit;
using Xunit.Abstractions;

namespace EventSourcingTests.Bugs;

public class document_and_event_operations_within_page : BugIntegrationContext
{
private readonly ITestOutputHelper _output;

public document_and_event_operations_within_page(ITestOutputHelper output)
{
_output = output;
}

[Fact]
public async Task failure_due_to_ordering_change()
{
Expand All @@ -26,7 +34,10 @@ public async Task failure_due_to_ordering_change()
theStore.Options.Projections.Add<SampleProjection>(ProjectionLifecycle.Inline);
theStore.Options.Projections.Add<SampleEventProjection>(ProjectionLifecycle.Inline);


using var session = theStore.LightweightSession("tenant");
session.Logger = new TestOutputMartenLogger(_output);

var mrCreated = new SamplesRolledUpCreated(Guid.NewGuid());
session.Events.StartStream(mrCreated.Id, mrCreated);
await session.SaveChangesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private static GeneratedType buildUpdateStreamVersion(GeneratedType builderType,
new TenantIdColumn().As<IStreamTableColumn>().GenerateAppendCode(configureCommand, 3);
}

configureCommand.Frames.AppendSql(" returning version");

builderType.MethodFor(nameof(EventDocumentStorage.UpdateStreamVersion))
.Frames.Code($"return new {assembly.Namespace}.{UpdateStreamVersionOperationName}({{0}});",
Use.Type<StreamAction>());
Expand Down

0 comments on commit b01ee81

Please sign in to comment.