Skip to content

fix(billing): register synckey parent for transaction entities#5

Merged
zooqueen merged 1 commit into
mainfrom
fix/transaction-parent-key
Feb 25, 2026
Merged

fix(billing): register synckey parent for transaction entities#5
zooqueen merged 1 commit into
mainfrom
fix/transaction-parent-key

Conversation

@zooqueen
Copy link
Copy Markdown
Contributor

Summary

  • Fix billing balance returning $0 for new deposits by registering orm.WithParent on the Transaction model
  • Root cause: the mixin bridge's Parent field (set in transaction.New()) wasn't propagating to the ORM's internal parent field during key allocation
  • The ORM's Key() method checks meta.ParentFn to set parent — without it, transactions get nil parent, so parent_id is NULL in SQLite, and ancestor queries (WHERE parent_id = '1') return nothing

Context

PR #4 fixed the ON CONFLICT clause to preserve parent_id on upsert, but the root cause was that parent_id was never set on INSERT. This PR fixes the INSERT path by ensuring the ORM always allocates transaction keys with the correct parent.

Test plan

  • CI passes
  • Deploy to K8s, create a deposit, verify GET /api/v1/billing/balance shows correct amount
  • Existing patched transactions still visible

Transaction entities must have a parent key (synckey/1) for ancestor
queries in the billing balance calculation. The parent was set in
transaction.New() but lost during ORM key allocation because the
mixin's Parent field didn't propagate to the ORM's internal parent.

Register a ParentFn via orm.WithParent so the ORM always sets the
correct parent key when allocating transaction entity keys.
@zooqueen zooqueen merged commit bf32f0f into main Feb 25, 2026
4 checks passed
@zooqueen zooqueen deleted the fix/transaction-parent-key branch February 25, 2026 19:38
hanzo-dev pushed a commit that referenced this pull request May 13, 2026
Transaction entities must have a parent key (synckey/1) for ancestor
queries in the billing balance calculation. The parent was set in
transaction.New() but lost during ORM key allocation because the
mixin's Parent field didn't propagate to the ORM's internal parent.

Register a ParentFn via orm.WithParent so the ORM always sets the
correct parent key when allocating transaction entity keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant