Description
Our SQLx-Next initiative (#1163) has been pushed back to 0.7.0 as we wait for Generic Associated Types to be stabilized, as GATs will make it possible to do a lot of cleanup in the API.
In the meantime, we've decided to backport a handful of features we're really excited for, as well as merge in some feature work from contributors that has been in the pipeline for a while.
Backport
- Generalized Query Placeholders ([Next] [Feature] Generalized query placeholders (including support for expanding arrays into multiple placeholders) #875)
Database-agnostic syntax for bind parameters, providing named parameters and comma-expansion for arrays.
Additionally, the query!()
family of macros will support implicit bindings from scope like that proposed for format_args!
in RFC #2795:
let bars = vec!["bar1", "bar2", "bar3"];
let baz = 1i32;
sqlx::query!("UPDATE foo SET baz = {baz} WHERE bar IN ({bars+})")
.execute(&mut conn)
.await?;
- Binding named parameters at runtime: ([Proposal] Support named bind parameters #199)
sqlx::query("INSERT INTO foo(bar, baz) VALUES (%bar, %baz)")
.bind_as("bar", &bar)
.bind_as("baz", &baz)
Contributions
- Switch to one-file-per-query for
query!()
offline mode (Move to one-file-per-query for sqlx-cli prepare #570)
Eliminates dealing with constant merge conflicts in sqlx-data.json
with multiple people contributing to the same repository.
The macros will be able to save their data automatically which means you shouldn't need to remember cargo sqlx prepare
as long as you've built the project at least once after adding or changing a macro definition.
Compiling in offline mode should be faster as projects with many query!()
invocations won't need to repeatedly re-parse the same gigantic file. This would be further improved by using a binary file format supporting zero-copy parsing, like Cap'N'Proto.
- (released 0.5.9) implement support for Postgres'
COPY [FROM | TO] STDIN
(Add support for COPY ... FROM STDIN and COPY ... TO STDOUT statements in PostgreSQL #36)
The PR currently open (#1345) implements a basic low-level API which we can build on later with a strongly typed interface. Still, if you're looking to shove a giant CSV file into your database, this would be the place to start.
- Refactor Postgres array support (Rewrite Postgres array type handling #1385)
This should finally allow use of Vec<T>
where T
is a custom type with #[derive(sqlx::Type)]
.
-
Support client certificates for TLS with Postgres (Postgres native tls does not support client certificates. #1162)
-
(released 0.5.9) Support the
immutable
option for SQLite connections (Support the immutable option on SQLite connections #1289)
Misc
- Add support for
time 0.3
(time
dependency out of date #1277)
We will probably need to retain support for time 0.2
under a time-02
feature for at least the next couple releases.