16 KiB
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.3.5 - 2020-05-06
Fixed
-
[#281] Deallocate SQLite statements before closing the SQLite connection [@hasali19]
-
[#284] Fix handling of
0forBigDecimalin PostgreSQL and MySQL [@abonander]
Added
-
[#256] Add
query_unchecked!andquery_file_unchecked!with similar semantics toquery_as_unchecked![@meh] -
[#252] [#297] Derive serveral traits for the
Json<T>wrapper type [@meh] -
[#261] Add support for
#[sqlx(rename_all = "snake_case")]to#[derive(Type)][@shssoichiro] -
[#253] Add support for UNIX domain sockets to PostgreSQL [@Nilix007]
-
[#251] Add support for textual JSON on MySQL [@blackwolf12333]
-
[#275] [#268] Optionally log formatted SQL queries on execution [@shssoichiro]
-
[#267] Support Cargo.toml relative
.envfiles; allows for each crate in a workspace to use their own.envfile and thus their ownDATABASE_URL[@xyzd]
0.3.4 - 2020-04-10
Fixed
-
[#241] Type name for custom enum is not always attached to TypeInfo in PostgreSQL
-
[#237] [#238] User-defined type name matching is now case-insensitive in PostgreSQL [@qtbeee]
-
[#231] Handle empty queries (and those with comments) in SQLite
-
[#228] Provide
MapRowimplementations for functions (enables.map(|row| ...)over.try_map(|row| ...))
Added
-
[#234] Add support for
NUMERICin MySQL with thebigdecimalcrate [@xiaopengli89] -
[#227] Support
#[sqlx(rename = "new_name")]on struct fields within aFromRowderive [@sidred]
0.3.3 - 2020-04-01
Fixed
- [#214] Handle percent-encoded usernames in a database URL [@jamwaffles]
Changed
-
[#216] Mark
Cursor,Query,QueryAs,query::Map, andTransactionas#[must_use][@Ace4896] -
[#213] Remove matches dependency and use matches macro from std [@nrjais]
0.3.2 - 2020-03-31
Fixed
- [#212] Removed sneaky
println!inMySqlCursor
0.3.1 - 2020-03-30
Fixed
-
[#203] Allow an empty password for MySQL
-
[#204] Regression in error reporting for invalid SQL statements on PostgreSQL
-
[#200] Fixes the incorrect handling of raw (
r#...) fields of a struct in theFromRowderive [@sidred]
0.3.0 - 2020-03-29
Breaking Changes
-
sqlx::Rownow has a lifetime ('c) tied to the database connection. In effect, this means that you cannot storeRows or collect them into a collection.Query(returned fromsqlx::query()) hasmap()which takes a function to map from theRowto another type to make this transition easier.In 0.2.x
let rows = sqlx::query("SELECT 1") .fetch_all(&mut conn).await?;In 0.3.x
let values: Vec<i32> = sqlx::query("SELECT 1") .map(|row: PgRow| row.get(0)) .fetch_all(&mut conn).await?;To assist with the above,
sqlx::query_as()now supports querying directly into tuples (up to 9 elements) or struct types with a#[derive(FromRow)].// This extension trait is needed until a rust bug is fixed use sqlx::postgres::PgQueryAs; let values: Vec<(i32, bool)> = sqlx::query_as("SELECT 1, false") .fetch_all(&mut conn).await?; -
HasSqlType<T>: Databaseis nowT: Type<Database>to mirrorEncodeandDecode -
Query::fetch(returned fromquery()) now returns a newCursortype.Cursoris a Stream-like type where the item type borrows into the stream (which itself borrows from connection). This means that usingquery().fetch()you can now stream directly from the database with zero-copy and zero-allocation. -
Remove
PgTypeInfo::with_oidand replace withPgTypeInfo::with_name
Added
-
Results from the database are now zero-copy and no allocation beyond a shared read buffer for the TCP stream ( in other words, almost no per-query allocation ). Bind arguments still do allocate a buffer per query.
-
[#129] Add support for SQLite. Generated code should be very close to normal use of the C API.
- Adds
Sqlite,SqliteConnection,SqlitePool, and other supporting types
- Adds
-
[#97] [#134] Add support for user-defined types. [@Freax13]
-
Rust-only domain types or transparent wrappers around SQL types. These may be used transparently inplace of the SQL type.
#[derive(sqlx::Type)] #[repr(transparent)] struct Meters(i32); -
Enumerations may be defined in Rust and can match SQL by integer discriminant or variant name.
#[derive(sqlx::Type)] #[repr(i32)] // Expects a INT in SQL enum Color { Red = 1, Green = 2, Blue = 3 }#[derive(sqlx::Type)] #[sqlx(rename = "TEXT")] // May also be the name of a user defined enum type #[sqlx(rename_all = "lowercase")] // similar to serde rename_all enum Color { Red, Green, Blue } // expects 'red', 'green', or 'blue' -
Postgres further supports user-defined composite types.
#[derive(sqlx::Type)] #[sqlx(rename = "interface_type")] struct InterfaceType { name: String, supplier_id: i32, price: f64 }
-
-
[#98] [#131] Add support for asynchronous notifications in Postgres (
LISTEN/NOTIFY). [@thedodd]-
Supports automatic reconnection on connection failure.
-
PgListenerimplementsExecutorand may be used to execute queries. Be careful however as if the intent is to handle and process messages rapidly you don't want to be tying up the connection for too long. Messages received during queries are buffered and will be delivered on the next call torecv().
let mut listener = PgListener::new(DATABASE_URL).await?; listener.listen("topic").await?; loop { let message = listener.recv().await?; println!("payload = {}", message.payload); } -
-
Add unchecked variants of the query macros. These will still verify the SQL for syntactic and semantic correctness with the current database but they will not check the input or output types.
This is intended as a temporary solution until
query_as!is able to support user defined types.query_as_unchecked!query_file_as_unchecked!
-
Add support for many more types in Postgres
JSON,JSONB[@oeb25]INET,CIDR[@PoiScript]- Arrays [@oeb25]
- Composites ( Rust tuples or structs with a
#[derive(Type)]) NUMERIC[@abonander]OID(u32)"CHAR"(i8)TIMESTAMP,TIMESTAMPTZ, etc. with thetimecrate [@utter-step]- Enumerations ( Rust enums with a
#[derive(Type)]) [@Freax13]
Changed
-
Query(andQueryAs; returned fromquery(),query_as(),query!(), andquery_as!()) now will accept both&mut Connectionor&Poolwhere as in 0.2.x they required&mut &Pool. -
Executornow takes any value that implementsExecuteas a query.Executeis implemented forQueryandQueryAsto mean exactly what they've meant so far, a prepared SQL query. However,Executeis also implemented for just&strwhich now performs a raw or unprepared SQL query. You can further use this to fetchRows from the database though it is not as efficient as the prepared API (notably Postgres and MySQL send data back in TEXT mode as opposed to in BINARY mode).use sqlx::Executor; // Set the time zone parameter conn.execute("SET TIME ZONE LOCAL;").await // Demonstrate two queries at once with the raw API let mut cursor = conn.fetch("SELECT 1; SELECT 2"); let row = cursor.next().await?.unwrap(); let value: i32 = row.get(0); // 1 let row = cursor.next().await?.unwrap(); let value: i32 = row.get(0); // 2
Removed
-
Query(returned fromquery()) no longer hasfetch_one,fetch_optional, orfetch_all. You must map the row usingmap()and then you will have aquery::Mapvalue that has the former methods available.let values: Vec<i32> = sqlx::query("SELECT 1") .map(|row: PgRow| row.get(0)) .fetch_all(&mut conn).await?;
Fixed
-
[#62] [#130] [#135] Remove explicit set of
IntervalStyle. Allow usage of SQLx for CockroachDB and potentially PgBouncer. [@bmisiak] -
[#108] Allow nullable and borrowed values to be used as arguments in
query!andquery_as!. For example, where the column would resolve toStringin Rust (TEXT, VARCHAR, etc.), you may now useOption<String>,Option<&str>, or&strinstead. [@abonander] -
[#108] Make unknown type errors far more informative. As an example, trying to
SELECTaDATEcolumn will now try and tell you about thechronofeature. [@abonander]optional feature `chrono` required for type DATE of column #1 ("now")
0.2.6 - 2020-03-10
Added
Fixed
-
[#125] [#126] Fix statement execution in MySQL if it contains NULL statement values [@repnop]
-
[#105] [#109] Allow trailing commas in query macros [@timmythetiny]
0.2.5 - 2020-02-01
Fixed
-
Fix decoding of Rows containing NULLs in Postgres #104
-
After a large review and some battle testing by @ianthetechie of the
Pool, a live leaking issue was found. This has now been fixed by @abonander in #84 which included refactoring to make the pool internals less brittle (using RAII instead of manual work is one example) and to help any future contributors when changing the pool internals. -
Passwords are now being precent decoding before being presented to the server [@repnop]
-
[@100] Fix
FLOATandDOUBLEdecoding in MySQL
Added
-
[#72] Add
PgTypeInfo::with_oidto allow simple construction ofPgTypeInfowhich enablesHasSqlTypeto be implemented by downstream consumers of SQLx [@jplatte] -
[#96] Add support for returning columns from
query!with a name of a rust keyword by using raw identifiers [@yaahc] -
[#71] Implement derives for
EncodeandDecode. This is the first step to supporting custom types in SQLx. [@Freax13]
0.2.4 - 2020-01-18
Fixed
- Fix decoding of Rows containing NULLs in MySQL (and add an integration test so this doesn't break again)
0.2.3 - 2020-01-18
Fixed
- Fix
query!when used on a query that does not return results
0.2.2 - 2020-01-16
Added
Fixed
-
Fix stall when requesting TLS from a Postgres server that explicitly does not support TLS (such as postgres running inside docker) [@abonander]
-
[#66] Declare used features for
tokioinsqlx-macrosexplicitly
0.2.1 - 2020-01-16
Fixed
- [#64, #65] Fix decoding of Rows containing NULLs in MySQL [@danielakhterov]
- [#55] Use a shared tokio runtime for the
query!macro compile-time execution (under theruntime-tokiofeature) [@udoprog]
0.2.0 - 2020-01-15
Fixed
Added
-
Support Tokio through an optional
runtime-tokiofeature. -
Support SQL transactions. You may now use the
begin()function onPoolorConnectionto start a new SQL transaction. This returnssqlx::Transactionwhich willROLLBACKonDropor can be explicitlyCOMMITusingcommit(). -
Support TLS connections.
0.1.4 - 2020-01-11
Fixed
Added
-
Support for
SCRAM-SHA-256authentication in Postgres #37 @danielakhterov -
Implement
Debugfor Pool #42 @prettynatty
0.1.3 - 2020-01-06
Fixed
0.1.2 - 2020-01-03
Added
-
Support for Authentication in MySQL 5+ including the newer authentication schemes now default in MySQL 8:
mysql_native_password,sha256_password, andcaching_sha2_password. -
Chronosupport for MySQL was only partially implemented (was missingNaiveTimeandDateTime<Utc>). -
Vec<u8>(and[u8]) support for MySQL (BLOB) and Postgres (BYTEA).