Workspace-level `sqlx.toml`

Aperta
#4,293 1 commento 3 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
rust, sql

Direzione di ricerca

This is a design request for optional workspace-level sqlx.toml inheritance (opt-in from a crate sqlx.toml to a parent file), not a one-file patch. Start from how sqlx currently discovers and loads sqlx.toml relative to CARGO_MANIFEST_DIR, then decide merge vs override for keys like type-overrides and DATABASE_URL. Done means documented opt-in that works in a workspace checkout without breaking published crates that only have a per-crate file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
I have found these related issues/pull requests

No prior discussion that I could find.

Description

In a larger application it's common to break it up into multiple crates, which may involve different crates using sqlx for different parts of the database. These crates may share a lot of common configuration, such as preferred-crates or type-overrides.

Currently it appears to be possible to have a fully shared configuration via symlinking, which I do think satisfies my usecase for now, but could maybe be mentioned in the docs. That also handles publishing outside the workspace correctly: the symlink gets turned into a file copy in the tarball by cargo package. But it seems likely that there are cases where you want to share some but not all config, such as the different-DATABASE_URL cases but where you might expect all databases to be running a set of extensions. For an unpublished application that is designed to only compile as part of the workspace as a whole it would be possible for it to rely on reading files outside the CARGO_MANIFEST_DIR.

Prefered solution

Probably some explicit opt-in in the per-crate sqlx.toml telling it to read ../sqlx.toml that makes it clear this is slightly outside the bounds of what Cargo truly supports and will only work when building from the repository.

Is this a breaking change? Why or why not?

No, it would be a new functionality.

Lingua principale
Rust
Stelle
17.5k
Fork
1.7k
Merge medio
1g 17h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transact-rs/sqlx

Tutte le issue di transact-rs/sqlx

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.