fix(localdb): capture triggers survive consumer upserts (explicit ON CONFLICT upsert form, outer-statement override)

This commit is contained in:
Joseph Doherty
2026-07-18 00:57:27 -04:00
parent 801b042208
commit 154d584190
4 changed files with 88 additions and 31 deletions
@@ -190,11 +190,10 @@ public sealed class ConvergenceFixture : IAsyncDisposable
/// <summary>
/// Inserts or updates one row through the normal consumer API (fires the ai/au capture triggers).
/// Uses a plain UPDATE-else-INSERT inside one transaction — NOT <c>INSERT ... ON CONFLICT DO
/// UPDATE</c>: that upsert form crashes the AFTER-UPDATE capture trigger with
/// "UNIQUE constraint failed: __localdb_row_version" (see the Skipped regression test in
/// BidirectionalConvergenceTests). The transaction makes the update-or-insert atomic against a
/// concurrent replicated apply of the same pk (no INSERT/UNIQUE race on orders).
/// Uses a plain UPDATE-else-INSERT inside one transaction; the transaction makes the
/// update-or-insert atomic against a concurrent replicated apply of the same pk (no
/// INSERT/UNIQUE race on orders). <c>INSERT ... ON CONFLICT DO UPDATE</c> is also supported by
/// the capture triggers — covered by <c>Upsert_OnConflictDoUpdate_CapturesCorrectly</c>.
/// </summary>
public static async Task UpsertAsync(ILocalDb db, long id, string sku, long qty)
{