oxidecomputer / oxidecomputer/omicron

Need a check that field order in schema.rs matches order in dbinit.sql

Open
#4,570 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

While developing https://github.com/oxidecomputer/omicron/pull/4520 I encountered a mysterious error Received more than 8 bytes decoding i64. Was an expression of a different type misidentified as BigInt? (full error). It took a bit of debugging work to figure out that this was happening due to a mismatch in the field order between dbinit.sql and schema.rs.

We should have a check to ensure that the field order (and maybe types, if possible) match.

Another related issue is checking that the order of fields in a Queryable or Insertable struct is the same as that in the database.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read dbinit.sql and schema.rs first, then inspect the Queryable and Insertable structs mentioned in the issue to understand how field order is represented. Define whether the check covers only field order or types as well; done means mismatches are detected before they cause decoding errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.