oxidecomputer / oxidecomputer/omicron

Consider upstreaming CTE support

Open
#4,190 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

Background

https://github.com/oxidecomputer/omicron/pull/1733 introduced some utilities to build CTEs:

nexus/src/db/subquery.rs - Adds the definition of traits like Subquery, as well as a CteBuilder to help building arbitrary CTEs.
nexus/db-macros/src/lib.rs - Adds macro to derive Subquery (identifying that a query can be used in a CTE arm)
nexus/db-macros/src/subquery.rs - Implementation of Subquery macro
nexus/src/db/alias.rs - Defines expression which allows field aliasing (FOO as BAR in SELECT/RETURNING queries)
nexus/db-model/src/queries - Uses the table! macro to describe the columns of subqueries. This generates more code than we actually want!

Goal

It would be nice to simplify the "known hacky" pieces of this -- e.g. re-using the table! macro for subqueries -- and to upstream this support into Diesel, to ensure that we don't get broken by future Diesel revisions.

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 with the CTE utilities in nexus/src/db/subquery.rs and the related macro files nexus/db-macros/src/lib.rs and nexus/db-macros/src/subquery.rs, then review nexus/src/db/alias.rs and the queries under nexus/db-model/src/queries. Compare the existing table! use for subqueries with the desired Diesel upstream support; done means defining a concrete upstreamable design for these pieces.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.