51 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.5.13 - 2022-04-15
This is a hotfix that reverts #1748 as that was an accidental breaking change:
the generated PgHasArrayType
impl conflicts with manual impls of the trait.
This change will have to wait for 0.6.0.
0.5.12 - 2022-04-13 (Yanked; use 0.5.13)
27 pull requests were merged this release cycle.
Added
- [#1641]: Postgres: Convenient wrapper for advisory locks [@abonander]
- [#1675]: Add function to undo migrations [@jdrouet]
- [#1722]: Postgres: implement
PgHasArrayType
forserde_json::{Value, RawValue}
[@abreis] - [#1736]: Derive
Clone
forMySqlArguments
andMssqlArguments
[@0xdeafbeef] - [#1748]: Derive
PgHasArrayType
for#[sqlx(transparent)]
types [@carols10cents] - [#1754]: Include affected rows alongside returned rows in query logging [@david-mcgillicuddy-moixa]
- [#1757]: Implement
Type
forCow<str>
for MySQL, MSSQL and SQLite [@ipetkov] - [#1769]: sqlx-cli: add
--source
to migration subcommands [@pedromfedricci] - [#1774]: Postgres: make
extra_float_digits
settable [@abonander]- Can be set to
None
for Postgres or third-party database servers that don't support the option.
- Can be set to
- [#1776]: Implement close-event notification for Pool [@abonander]
- Also fixes
PgListener
preventingPool::close()
from resolving.
- Also fixes
- [#1780]: Implement query builder [@crajcan]
- See also [#1790]: Document and expand query builder [@abonander]
- [#1781]: Postgres: support
NUMERIC[]
usingdecimal
feature [@tm-drtina] - [#1784]: SQLite: add
FromStr
,Copy
,PartialEq
,Eq
impls for options enums [@andrewwhitehead]
Changed
- [#1625]: Update RustCrypto crates [@paolobarbolini]
- [#1725]: Update
heck
to 0.4 [@paolobarbolini] - [#1738]: Update
regex
[@Dylan-DPC] - [#1763]: SQLite: update
libsqlite3-sys
[@espindola]
Fixed
- [#1719]: Fix a link in
query!()
docs [@vbmade2000] - [#1731]: Postgres: fix option passing logic [@liushuyu]
- [#1735]: sqlx-cli: pass
DATABASE_URL
to command spawned inprepare
[@LovecraftianHorror] - [#1741]: Postgres: fix typo in
TSTZRANGE
[@mgrachev] - [#1761]: Fix link from
QueryAs
toquery_as()
in docs [@mgrachev] - [#1786]: MySQL: silence compile warnings for unused fields [@andrewwhitehead]
- [#1789]: SQLite: fix left-joins breaking
query!()
macros [@tyrelr] - [#1791]: Postgres: fix newline parsing of
.pgpass
files [@SebastienGllmt] - [#1799]:
PoolConnection
: don't leak connection permit if drop task fails to run [@abonander]
0.5.11 - 2022-02-17
20 pull requests were merged this release cycle.
Added
- [#1610]: Allow converting
AnyConnectOptions
to a specificConnectOptions
[@05storm26] - [#1652]: Implement
From
forAnyConnection
[@genusistimelord] - [#1658]: Handle
SQLITE_LOCKED
[@madadam] - [#1665]: Document offline mode usage with feature flags [@sedrik]
- [#1680]: Show checksum mismatches in
sqlx migrate info
[@ifn3] - [#1685]: Add tip for setting
opt-level
forsqlx-macros
[@LovecraftianHorror] - [#1687]: Docs:
Acquire
examples and alternative [@stoically] - [#1696]: Postgres: support for
ltree
[@cemoktra] - [#1710]: Postgres: support for
lquery
[@cemoktra]
Changed
- [#1605]: Remove unused dependencies [@paolobarbolini]
- [#1606]: Add target context to Postgres
NOTICE
logs [@dbeckwith] - [#1684]: Macros: Cache parsed
sqlx-data.json
instead of reparsing [@LovecraftianHorror]
Fixed
- [#1608]: Drop worker shared state in shutdown (SQLite) [@andrewwhitehead]
- [#1619]: Docs(macros): remove sentences banning usage of
as _
[@k-jun] - [#1626]: Simplify
cargo-sqlx
command-line definition [@tranzystorek-io] - [#1636]: Fix and extend Postgres transaction example [@taladar]
- [#1657]: Fix typo in macro docs [@p9s]
- [#1661]: Fix binding
Option<T>
forAny
driver [@ArGGu] - [#1667]: MySQL: Avoid panicking if packet is empty [@nappa85]
- [#1692]: Postgres: Fix power calculation when encoding
BigDecimal
intoNUMERIC
[@VersBinarii]
Additionally, we have introduced two mitigations for the issue of the cyclic dependency on ahash
:
- We re-downgraded our version requirement on
indexmap
from1.7.0
back to1.6.2
so users can pin it to that version as recommended in aHash#95. - Thanks to the work of @LovecraftianHorror in #1684, we no longer require the
preserve_order
feature ofserde_json
which gives users another place to break the cycle by simply not enabling that feature.- This may introduce extra churn in Git diffs for
sqlx-data.json
, however. If this is an issue for you but the dependency cycle isn't, you can re-enable thepreserve_order
feature:
[dependencies] serde_json = { version = "1", features = ["preserve_order"] }
- This may introduce extra churn in Git diffs for
0.5.10 - 2021-12-29
A whopping 31 pull requests were merged this release cycle!
According to this changelog, we saw 18 new contributors! However, some of these folks may have missed getting mentioned in previous entries since we only listed highlights. To avoid anyone feeling left out, I put in the effort this time and tried to list every single one here.
Added
- [#1228]: Add
Pool::any_kind()
[@nitnelave] - [#1343]: Add
Encode/Decode
impl forCow<'_, str>
[@Drevoed] - [#1474]: Derive
Clone
,Copy
forAnyKind
[@yuyawk] - [#1497]: Update FAQ to explain how to configure docs.rs to build a project using SQLx [@russweas]
- [#1498]: Add description of migration file structure to
migrate!()
docs [@zbigniewzolnierowicz] - [#1508]: Add
.persistent(bool)
toQueryAs
,QueryScalar
[@akiradeveloper] - [#1514]: Add support for serialized threading mode to SQLite [@LLBlumire]
- [#1523]: Allow
rust_decimal::Decimal
inPgRange
[@meh] - [#1539]: Support
PGOPTIONS
and adding custom configuration options inPgConnectOptions
[@liushuyu] - [#1562]: Re-export
either::Either
used byExecutor::fetch_many()
[@DoumanAsh] - [#1584]: Add feature to use RusTLS instead of
native-tls
forsqlx-cli
[@SonicZentropy] - [#1592]: Add
AnyConnection::kind()
[@05storm26]
Changes
- [#1385]: Rewrite Postgres array handling to reduce boilerplate and allow custom types [@jplatte]
- [#1479]: Remove outdated mention of
runtime-async-std-native-tls
as the default runtime in README.md [@yerke] - [#1526]: Revise
Pool
docs in a couple places [@abonander] - [#1535]: Bump
libsqlite-sys
to0.23.1
[@nitsky] - [#1551]: SQLite: make worker thread responsible for all FFI calls [@abonander]
- If you were encountering segfaults with the SQLite driver, there's a good chance this will fix it!
- [#1557]: CI: test with Postgres 14 [@paolobarbolini]
- [#1571]: Make
whoami
dep optional, only pull it in for Postgres [@joshtriplett] - [#1572]: Update
rsa
crate to 0.5 [@paolobarbolini] - [#1591]: List SeaORM as an ORM option in the README [@kunjee17]
- [#1601]: Update
itoa
anddirs
[@paolobarbolini]
Fixes
- [#1475]: Fix panic when converting a negative
chrono::Duration
toPgInterval
[@yuyawk] - [#1483]: Fix error when decoding array of custom types from Postgres [@demurgos
- [#1501]: Reduce
indexmap
version requirement to1.6.2
[@dimfeld] - [#1511]: Fix element type given to Postgres for arrays of custom enums [@chesedo]
- [#1517]: Fix mismatched type errors in MySQL type tests [@abonander]
- [#1537]: Fix missing re-export of
PgCopyIn
[@akiradeveloper] - [#1566]: Match
~/.pgpass
password after URL parsing and fix user and database ordering [@D1plo1d] - [#1582]:
cargo sqlx prepare
: Append to existingRUSTFLAGS
instead of overwriting [@tkintscher] - [#1587]: SQLite: if set, send
PRAGMA key
on a new connection before anything else. [@parazyd]- This should fix problems with being unable to open databases using SQLCipher.
0.5.9 - 2021-10-01
A hotfix release to address the issue of the sqlx
crate itself still depending on older versions of sqlx-core
and
sqlx-macros
.
No other changes from 0.5.8
.
0.5.8 - 2021-10-01 (Yanked; use 0.5.9)
A total of 24 pull requests were merged this release cycle! Some highlights:
- [#1289] Support the
immutable
option on SQLite connections [@djmarcin] - [#1295] Support custom initial options for SQLite [@ghassmo]
- Allows specifying custom
PRAGMA
s and overriding those set by SQLx.
- Allows specifying custom
- [#1345] Initial support for Postgres
COPY FROM/TO
[@montanalow, @abonander] - [#1439] Handle multiple waiting results correctly in MySQL [@eagletmt]
0.5.7 - 2021-08-20
- [#1392] use
resolve_path
when getting path forinclude_str!()
[@abonander]- Fixes a regression introduced by [#1332].
- [#1393] avoid recursively spawning tasks in
PgListener::drop()
[@abonander]- Fixes a panic that occurs when
PgListener
is dropped inasync fn main()
.
- Fixes a panic that occurs when
0.5.6 - 2021-08-16
A large bugfix release, including but not limited to:
- [#1329] Implement
MACADDR
type for Postgres [@nomick] - [#1363] Fix
PortalSuspended
for array of composite types in Postgres [@AtkinsChang] - [#1320] Reimplement
sqlx::Pool
internals usingfutures-intrusive
[@abonander]- This addresses a number of deadlocks/stalls on acquiring connections from the pool.
- [#1332] Macros: tell the compiler about external files/env vars to watch [@abonander]
- Includes
sqlx build-script
to create abuild.rs
to watchmigrations/
for changes. - Nightly users can try
RUSTFLAGS=--cfg sqlx_macros_unstable
to tell the compiler to watchmigrations/
for changes instead of using a build script. - See the new section in the docs for
sqlx::migrate!()
for details.
- Includes
- [#1351] Fix a few sources of segfaults/errors in SQLite driver [@abonander]
- [#1323] Keep track of column typing in SQLite EXPLAIN parsing [@marshoepial]
- This fixes errors in the macros when using
INSERT/UPDATE/DELETE ... RETURNING ...
in SQLite.
- This fixes errors in the macros when using
A total of 25 pull requests were merged this release cycle!
0.5.5 - 2021-05-24
0.5.4 - 2021-05-22
0.5.3 - 2021-05-21
-
[#1211] Even more tweaks and fixes to the Pool internals [@abonander]
-
[#1213] Add support for bytes and
chrono::NaiveDateTime
toAny
[@guylapid] -
[#1224] Add support for
chrono::DateTime<Local>
toAny
withMySQL
[@NatPRoach] -
[#1216] Skip empty lines and comments in pgpass files [@feikesteenbergen]
-
[#1218] Add support for
PgMoney
to the compile-time type-checking [@iamsiddhant05]
0.5.2 - 2021-04-15
-
[#1149] Tweak and optimize Pool internals [@abonander]
-
[#1132] Remove
'static
bound onConnection::transaction
[@argv-minus-one] -
[#1099] [#1097] Truncate buffer when
BufStream
is dropped [@Diggsey]
PostgreSQL
-
[#1170] Remove
Self: Type
bounds inEncode
/Decode
implementations for arrays [@jplatte]Enables working around the lack of support for user-defined array types:
#[derive(sqlx::Encode)] struct Foos<'a>(&'a [Foo]); impl sqlx::Type<sqlx::Postgres> for Foos<'_> { fn type_info() -> PgTypeInfo { PgTypeInfo::with_name("_foo") } } query_as!( Whatever, "<QUERY with $1 of type foo[]>", Foos(&foo_vec) as _, )
-
[#1141] Use
u16::MAX
instead ofi16::MAX
for a check against the largest number of parameters in a query [@crajcan] -
[#1100] Explicitly
UNLISTEN
before returning connections to the pool inPgListener
[@Diggsey]
SQLite
-
[#1161] Catch
SQLITE_MISUSE
on connection close and panic [@link2xt] -
[#1160] Do not cast pointers to
i32
(cast tousize
) [@link2xt] -
[#1156] Reset the statement when
fetch_many
stream is dropped [@link2xt]
0.5.1 - 2021-02-04
- Update sqlx-rt to 0.3.
0.5.0 - 2021-02-04
Changes
-
[#983] [#1022] Upgrade async runtime dependencies [@seryl, @ant32, @jplatte, @robjtede]
- tokio 1.0
- actix-rt 2.0
-
[#854] Allow chaining
map
andtry_map
[@jplatte]Additionally enables calling these combinators with the macros:
let ones: Vec<i32> = query!("SELECT 1 as foo") .map(|row| row.foo) .fetch_all(&mut conn).await?;
-
[#940] Rename the
#[sqlx(rename)]
attribute used to specify the type name on the database side to#[sqlx(type_name)]
[@jplatte]. -
[#976] Remove the
Done
trait. The.rows_affected()
method is now available as an inherent method onPgQueryResult
,MySqlQueryResult
and so on. [@jplatte] -
[#1007] Remove
any::AnyType
(and replace with directly implementingType<Any>
) [@jplatte]
Added
-
[#919] For SQLite, add support for unsigned integers [@dignifiedquire]
Fixes
-
[#1002] For SQLite,
GROUP BY
inquery!
caused an infinite loop at compile time. [@pymongo] -
[#979] For MySQL, fix support for non-default authentication. [@sile]
-
[#918] Recover from dropping
wait_for_conn
inside Pool. [@antialize]
0.4.2 - 2020-12-19
-
[#908] Fix
whoami
crash on FreeBSD platform [@fundon] [@AldaronLau] -
[#895] Decrement pool size when connection is released [@andrewwhitehead]
-
[#878] Fix
conn.transaction
wrapper [@hamza1311]conn.transaction(|transaction: &mut Transaction<Database> | { // ... });
-
[#860] Add
rename_all
toFromRow
and addcamelCase
andPascalCase
[@framp] -
[#839] Add (optional) support for
bstr::BStr
,bstr::BString
, andgit2::Oid
[@joshtriplett]
SQLite
-
[#852] Fix potential 100% CPU usage in
fetch_one
/fetch_optional
[@markazmierczak] -
[#850] Add
synchronous
option toSqliteConnectOptions
[@markazmierczak]
PostgreSQL
-
[#876] Add support for
BYTEA[]
to compile-time type-checking [@augustocdias]
MySQL
0.4.1 – 2020-11-13
Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in Cargo.toml
.
0.4.0 - 2020-11-12
-
[#774] Fix usage of SQLx derives with other derive crates [@NyxCode]
-
[#762] Fix
migrate!()
(with no params) [@esemeniuc] -
[#755] Add
kebab-case
torename_all
[@iamsiddhant05] -
[#735] Support
rustls
[@jplatte]Adds
-native-tls
or-rustls
on each runtime feature:# previous features = [ "runtime-async-std" ] # now features = [ "runtime-async-std-native-tls" ]
-
[#718] Support tuple structs with
#[derive(FromRow)]
[@dvermd]
SQLite
-
[#784] Use
futures_channel::oneshot
in worker for big perf win [@markazmierczak]
PostgreSQL
-
[#745] Always prefer parsing of the non-localized notice severity field [@dstoeckel]
MySQL
-
[#743] Consider
utf8mb4_bin
as a string @digorithm -
[#739] Fix minor protocol detail with
iteration-count
that was blocking Vitess [@mcronce]
0.4.0-beta.1 - 2020-07-27
Highlights
-
Enable compile-time type checking from cached metadata to enable building in an environment without access to a development database (e.g., Docker, CI).
-
Initial support for Microsoft SQL Server. If there is something missing that you need, open an issue. We are happy to help.
-
SQL migrations, both with a CLI tool and programmatically loading migrations at runtime.
-
Runtime-determined database driver,
Any
, to support compile-once and run with a database driver selected at runtime. -
Support for user-defined types and more generally overriding the inferred Rust type from SQL with compile-time SQL verification.
Fixed
MySQL
- [#418] Support zero dates and times [@blackwolf12333]
Added
-
[#174] Inroduce a builder to construct connections to bypass the URI parsing
// MSSQL let conn = MssqlConnectOptions::new() .host("localhost") .database("master") .username("sa") .password("Password") .connect().await?; // SQLite let conn = SqliteConnectOptions::from_str("sqlite://a.db")? .foreign_keys(false) .connect().await?;
-
[#127] Get the last ID or Row ID inserted for MySQL or SQLite
// MySQL let id: u64 = query!("INSERT INTO table ( col ) VALUES ( ? )", val) .execute(&mut conn).await? .last_insert_id(); // LAST_INSERT_ID() // SQLite let id: i64 = query!("INSERT INTO table ( col ) VALUES ( ?1 )", val) .execute(&mut conn).await? .last_insert_rowid(); // sqlite3_last_insert_rowid()
-
[#263] Add hooks to the Pool:
after_connect
,before_release
, andafter_acquire
// PostgreSQL let pool = PgPoolOptions::new() .after_connect(|conn| Box::pin(async move { conn.execute("SET application_name = 'your_app';").await?; conn.execute("SET search_path = 'my_schema';").await?; Ok(()) })) .connect("postgres:// …").await?
-
[#308] [#495] Extend
derive(FromRow)
with support for#[sqlx(default)]
on fields to allow reading in a partial query [@OriolMunoz] -
[#454] #456 Support
rust_decimal::Decimal
as an alternative tobigdecimal::BigDecimal
forNUMERIC
columns in MySQL and PostgreSQL [@pimeys] -
[#181] Column names and type information is now accessible from
Row
viaRow::columns()
orRow::column(name)
PostgreSQL
- [#197] [#271] Add initial support for
INTERVAL
(full support pending atime::Period
type) [@dimtion]
MySQL
SQLite
-
Types are now inferred for expressions. This means its now possible to use
query!
andquery_as!
for:let row = query!("SELECT 10 as _1, x + 5 as _2 FROM table").fetch_one(&mut conn).await?; assert_eq!(row._1, 10); assert_eq!(row._2, 5); // 5 + x?
-
[#167] Support
foreign_keys
explicitly with aforeign_keys(true)
method available onSqliteConnectOptions
which is a builder for new SQLite connections (and can be passed intoPoolOptions
to build a pool).let conn = SqliteConnectOptions::new() .foreign_keys(true) // on by default .connect().await?;
-
[#430] [#438] Add method to get the raw SQLite connection handle [@agentsim]
// conn is `SqliteConnection` // this is not unsafe, but what you do with the handle will be let ptr: *mut libsqlite3::sqlite3 = conn.as_raw_handle();
-
[#164] Support
TIMESTAMP
,DATETIME
,DATE
, andTIME
viachrono
in SQLite [@felipesere] [@meteficha]
Changed
-
Transaction
now mutably borrows a connection instead of owning it. This enables a new (or nested) transaction to be started from&mut conn
. -
[#145] [#444] Use a least-recently-used (LRU) cache to limit the growth of the prepared statement cache for SQLite, MySQL, and PostgreSQL [@pimeys]
SQLite
- [#499]
INTEGER
now resolves toi64
instead ofi32
,INT4
will still resolve toi32
Removed
0.3.5 - 2020-05-06
Fixed
-
[#281] Deallocate SQLite statements before closing the SQLite connection [@hasali19]
-
[#284] Fix handling of
0
forBigDecimal
in 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
.env
files; allows for each crate in a workspace to use their own.env
file 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
MapRow
implementations for functions (enables.map(|row| ...)
over.try_map(|row| ...)
)
Added
-
[#234] Add support for
NUMERIC
in MySQL with thebigdecimal
crate [@xiaopengli89] -
[#227] Support
#[sqlx(rename = "new_name")]
on struct fields within aFromRow
derive [@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
, andTransaction
as#[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 theFromRow
derive [@sidred]
0.3.0 - 2020-03-29
Breaking Changes
-
sqlx::Row
now has a lifetime ('c
) tied to the database connection. In effect, this means that you cannot storeRow
s or collect them into a collection.Query
(returned fromsqlx::query()
) hasmap()
which takes a function to map from theRow
to 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>: Database
is nowT: Type<Database>
to mirrorEncode
andDecode
-
Query::fetch
(returned fromquery()
) now returns a newCursor
type.Cursor
is 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_oid
and 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.
-
PgListener
implementsExecutor
and 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 thetime
crate [@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 Connection
or&Pool
where as in 0.2.x they required&mut &Pool
. -
Executor
now takes any value that implementsExecute
as a query.Execute
is implemented forQuery
andQueryAs
to mean exactly what they've meant so far, a prepared SQL query. However,Execute
is also implemented for just&str
which now performs a raw or unprepared SQL query. You can further use this to fetchRow
s 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::Map
value 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 toString
in Rust (TEXT, VARCHAR, etc.), you may now useOption<String>
,Option<&str>
, or&str
instead. [@abonander] -
[#108] Make unknown type errors far more informative. As an example, trying to
SELECT
aDATE
column will now try and tell you about thechrono
feature. [@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
FLOAT
andDOUBLE
decoding in MySQL
Added
-
[#72] Add
PgTypeInfo::with_oid
to allow simple construction ofPgTypeInfo
which enablesHasSqlType
to 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
Encode
andDecode
. 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
tokio
insqlx-macros
explicitly
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-tokio
feature) [@udoprog]
0.2.0 - 2020-01-15
Fixed
Added
-
Support Tokio through an optional
runtime-tokio
feature. -
Support SQL transactions. You may now use the
begin()
function onPool
orConnection
to start a new SQL transaction. This returnssqlx::Transaction
which willROLLBACK
onDrop
or can be explicitlyCOMMIT
usingcommit()
. -
Support TLS connections.
0.1.4 - 2020-01-11
Fixed
Added
-
Support for
SCRAM-SHA-256
authentication in Postgres #37 @danielakhterov -
Implement
Debug
for 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
. -
Chrono
support for MySQL was only partially implemented (was missingNaiveTime
andDateTime<Utc>
). -
Vec<u8>
(and[u8]
) support for MySQL (BLOB
) and Postgres (BYTEA
).