oxidecomputer / oxidecomputer/omicron
[diesel] CTE should reference columns explicitly
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
(Follow-up from #192)
Within the CTE implementation in db/update_and_check.rs, we use the statement RETURNING * to extract the results of the
UPDATE subquery. Additionally, when selecting from the JOIN of the SELECT and UPDATE queries, we access found.* to wild-card access the found structure.
This works, but isn't the best for backwards compatibility. If we add a column to the DB, but still run the old version of software, this risks bumping into migration issues - we'll accidentally read "more columns than we know how to parse".
In contrast, nearly all native Diesel operations select on columns explicitly. Using the traits provided within Diesel, it should be possible to do the same for this CTE, and would protect against these migration issues.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in db/update_and_check.rs and inspect the CTE implementation, especially the UPDATE subquery's RETURNING * and the JOIN's found.* access. Read the surrounding Diesel traits and native operations that select columns explicitly. Done means the CTE references known columns explicitly instead of relying on wildcard results, preserving compatibility with added database columns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- database
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100