oxidecomputer / oxidecomputer/omicron

[diesel] CTE should reference columns explicitly

Open
#210 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

database
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.