Skip to content

Fix swapped parent/child sides in patch consolidation merge#153

Merged
larsewi merged 1 commit intomasterfrom
fix-patch-merge-order
May 7, 2026
Merged

Fix swapped parent/child sides in patch consolidation merge#153
larsewi merged 1 commit intomasterfrom
fix-patch-merge-order

Conversation

@larsewi
Copy link
Copy Markdown
Owner

@larsewi larsewi commented May 7, 2026

Summary

  • merge_block_deltas treated the incoming block as the parent and the running result as the child, but blocks are iterated oldest-first, so the running result is the older delta and should be the parent.

  • The swap caused multi-block patches to either silently fall back to a full state TRUNCATE+INSERT (when a merge rule errored under the swap) or, for two consecutive updates on the same column, produce a degenerate update with old == new that sparse-encoded into an empty SET clause:

    BEGIN;
    UPDATE "products" SET  WHERE "id" = 3;
    COMMIT;
    
  • Regression test test_consecutive_updates_same_column_consolidate reproduces the original report (two consecutive price updates on the same row) and asserts a delta-path patch with the correct final value.

merge_block_deltas treated the incoming block as the parent and the
running result as the child, but blocks are iterated oldest-first, so
the running result is the older delta and should be the parent. The
swap caused multi-block patches to either silently fall back to a full
state TRUNCATE+INSERT (when a merge rule errored) or, for two
consecutive updates on the same column, produce a degenerate update
with old == new that sparse-encoded into an empty SET clause.

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@larsewi larsewi added the bug Bug fix label May 7, 2026
@larsewi larsewi merged commit 859de03 into master May 7, 2026
6 checks passed
@larsewi larsewi deleted the fix-patch-merge-order branch May 7, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant