mirror of
https://github.com/hanzoai/commerce.git
synced 2026-11-23 18:55:39 +00:00
Postgres wrote a row with encoding/json, under json tags with zeros left out, while SQLite writes it under each field's Go name (first letter lowered) with every field, and every filter names a field by its Go name. On Postgres a filter on a field whose tag is not its name never matched (a coupon's Code_ is tagged "code"), a false or a 0 never matched a row that left it out, and a cleared field read back unchanged. Postgres now writes this codec's keys, so it stores and filters as SQLite does, and beside them every json-tag key the row's old encoding held, so an image from before reads a row written now. One reader serves both: by Go name first, then by the json tag a row written before this holds. A false or a 0 matches a row that leaves the field out, on Postgres as on SQLite. SQLite's writer is unchanged. A row looked up by an id that is its own string id (an idempotent write's deterministic "gcr_<hash>") is found by a key of the query's kind: Postgres matches a key's kind exactly, so the kind-less key a failed decode yields never found it, and a gift card redeemed again under its key was debited twice. A test walks every registered model for a key two fields would share; the one found (an analytics integration's Disabled and its display copy Disabled_) is one fact, and is named as such. Claude-Session: https://claude.ai/code/session_016DKtyuzxU43Gsc6Pm9vKTF