[Feature] Improvements to QueryBuilder
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 22/100
Direzione di ricerca
This is a design-level change to QueryBuilder: reusable bind IDs (Postgres), storing SQL/binds as a Vec until build time so queries can nest and concatenate, and a format_sql! macro that keeps some static checking. Start from the existing QueryBuilder API (including sql vs into_sql) and how binds are numbered today. Done means the three capabilities work without breaking into_sql, with tests for nested queries and repeated binds; the sql method may be dropped.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The QueryBuilder is adequate for building a query in order, but it has several drawbacks:
- It's not possible to refer to the same "bind" parameter multiple times (this might be a Postgres-only feature).
- It's not possible to build queries "out of order". This happens if eg. I want to build a query, then wrap the entire thing as a subquery within some outer query. The code building the subquery has to be refactored to work with a mutable borrow of the same parent query.
- All static analysis of the queries are lost.
Prefered solution
-
There should be two Postgres-specific extension methods. One that pushes a new bind and returns an opaque "ID" for that bind. A second that pushes a reference to a previous bind by "ID".
-
The QueryBuilder should store everything internally as a
Vec<SqlOrBind>, and only convert to a string representation when the query is actually built. This way queries can be concatenated, one query can be used inside another, etc. without messing up the bind parameters. (When they are concatenated, all of the binds in the second query are automatically adjusted to not conflict with any binds from the first query) -
The QueryBuilder should support a
format!style macro, where the user can annotate format arguments with the type of SQL AST node they correspond to. For example:format_sql!("SELECT * FROM foo WHERE {:expression} LIMIT 2"). This would produce a statically checked query like thequery!macros, where during checking, the format argument is replaced by a suitable placeholder (eg. NULL for an expression). These format arguments should themselves be QueryBuilders, so that complex parts of the SQL can be built dynamically while still retaining some static checking.
Is this a breaking change? Why or why not?
The sql method on QueryBuilder cannot easily be supported with these changes (although into_sql is fine).
- Lingua principale
- Rust
- Stelle
- 17.5k
- Fork
- 1.7k
- Merge medio
- 1g 17h
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di transact-rs/sqlx
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
transact-rs/sqlx#4466 ·
I maintainer di solito rispondono entro 4 giorni
-
MySQL: ENUM and SET columns with a binary collation are named BINARY or CHARForse già presa @CodeMasterXZT l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4453 ·
I maintainer di solito rispondono entro 4 giorni
-
Postgres text arrays: a quoted "NULL" element is decoded as SQL NULLForse già presa @MinJaeRun l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4452 ·
I maintainer di solito rispondono entro 4 giorni
-
Fetch stream ends after first error using query macrosForse già presa @barry3406 l’ha presa 207 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4126 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
transact-rs/sqlx#3963 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di transact-rs/sqlx
Issue simili
-
priority: low ☕️ type: bug 🐛
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
area:docs documentation good first issue priority:medium
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
rtk-ai/rtk#4958 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
calagopus/panel#285 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agent-self
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
yologdev/yoyo-evolve#1117 · 1 commento ·
-
[Bug]: streamed Responses API flex_unavailable error maps to 500 InternalServerError instead of 429Apertallm translation
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 85/100
BerriAI/litellm#49736 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno