Column order is not load-bearing for table rows, and the docs say it is #32
Labels
No labels
area:defold
area:docs
area:infra
area:protocol
area:testing
kind:bug
kind:chore
phase:breadth
phase:core
phase:hardening
phase:slice
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
yuris/spacetimedb-defold#32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The generator, the README and a test all assert that column order is what gives row fields their names, on the grounds that rows are positional JSON arrays. Captured wire data from a live 2.8.2 server says table rows are named objects.
Evidence
dev/test/fixtures/session.jsonl, first inserted row of anInitialSubscription:A named object. Meanwhile
gen-schema.shopens with:and stamps the same claim into every generated file:
The decoder is already right —
protocol.decode_rowchecks for any known column name and returns the object as-is, falling back to positional only when none matches (stdb/protocol.lua:156-165). So there is no bug in the code. The doctrine around it is wrong, and it is load-bearing doctrine: it justifies the generator's existence, the "reorder a column and every client mis-maps fields" warning, and a fixture test asserting column order.What is actually true
From v2.8.2 source: table rows serialize through
RowRef's schema-aware impl (crates/table/src/table.rs:2034), producing a named product. Views project through a different path that produces positional arrays. So the positional branch is not dead code — it is the view path, and possibly older servers — but it is not what a normal table subscription hits.Work
one_off_queryresults,SubscribeAppliedvsSubscribeMultiApplied, and older?version=schema endpoints. Capture a fixture of each rather than reasoning about itgen-schema.sh, the generated file header and the README to say what is true, including why the positional fallback still existsWhy bother, given nothing is broken
Because the reason to keep the generator is still excellent and currently mis-stated. Column order is needed for the positional cases, and once typed codegen lands, column types are needed for decoding — a far stronger justification than the one in the file. A comment that confidently explains a mechanism which does not apply is how the next person builds on a false premise, and this repo is otherwise unusually careful about exactly that.
Priority
Low effort, and it should land before 1.0 simply because for a library the README is the product.