sqlx/CHANGELOG.md
Austin Bonander b4cce67b83 fix(changelog): correct release date for 0.7.3
also fix formatting for 0.6.3 cause it was bugging me
2023-11-22 18:11:58 -08:00

100 KiB
Raw Blame History

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.7.3 - 2023-11-22

38 pull requests were merged this release cycle.

Added

Changed

  • [#2701]: Remove documentation on offline feature [@Baptistemontan]
  • [#2713]: Add additional info regarding using Transaction and PoolConnection as… [@satwanjyu]
  • [#2770]: Update README.md [@snspinn]
  • [#2797]: doc(mysql): document behavior regarding BOOLEAN and the query macros [@abonander]
  • [#2803]: Don't use separate temp dir for query jsons (2) [@mattfbacon]
  • [#2819]: postgres begin cancel safe [@conradludgate]
  • [#2832]: Update extra_float_digits default to 2 instead of 3 [@brianheineman]
  • [#2865]: Update Faq - Bulk upsert with optional fields [@Vrajs16]
  • [#2880]: feat: use specific message for slow query logs [@abonander]
  • [#2882]: Do not require db url for prepare [@tamasfe]
  • [#2890]: doc(sqlite): cover lack of NUMERIC support [@abonander]
  • [No PR]: Upgraded libsqlite3-sys to 0.27.0
    • Note: linkage to libsqlite3-sys is considered semver-exempt; see the release notes for 0.7.0 below for details.

Fixed

0.7.2 - 2023-09-25

23 pull requests were merged this release cycle.

Added

  • [#2121]: Add JSON support to FromRow derive [@95ulisse]
  • [#2533]: Implement mysql_clear_password [@ldanilek]
  • [#2538]: cli: add --target-version CLI flags for migrate run/revert [@inahga]
  • [#2577]: supplement Postgres listen example with a small chat example [@JockeM]
  • [#2602]: Support naming migrations sequentially [@vmax]
  • [#2634]: Adding PgHasArrayType for &[u8;N] [@snf]
  • [#2646]: Support for setting client certificate and key from bytes [@wyhaya]
  • [#2664]: Automatically infer migration type [@vmax]
  • [#2712]: Add impl for Type, Decode, and Encode for Box<str> and Box<[u8]> [@grant0417]

Changed

  • [#2650]: Cleanup format arguments [@nyurik]
  • [#2695]: remove &mut PoolConnection from Executor docs [@olback]
    • This impl was removed in 0.7.0 because of coherence issues.
  • [#2706]: Clarify where optional features should be enabled [@kryptan]
  • [#2717]: Update README.md [@fermanjj]
  • [#2739]: Bump mariadb CI images + mysql unpin [@grooverdan]
  • [#2742]: Implemented poll_flush for Box<S:Socket> [@bobozaur]
  • [#2740]: Remove sealed trait comments from documentation [@bobozaur]
  • [#2750]: Fix #2384, bump flume to v0.11.0 [@madadam]
  • [#2757]: Remove unused remove_dir_all crate from sqlx-cli, fixes RUSTSEC-2023-0018 [@aldur]

Fixed

0.7.1 - 2023-07-14

This release mainly addresses issues reported with the 0.7.0 release.

16 pull requests were merged this release cycle.

Added

  • [#2551]: Introduce build_query_scalar for QueryBuilder [@iamquang95]
  • [#2605]: Implement Default for QueryBuilder [@Xydez]
  • [#2616]: feat(sqlx-core): add table function to database error [@saiintbrisson]
  • [#2619]: feat: allow opt-out of PgHasArrayType with #[derive(sqlx::Type)] [@abonander]
    • TL;DR: if you're getting errors from #[derive(sqlx::Type)] with #[sqlx(transparent)] regarding PgHasArrayType not being implemented, add #[sqlx(no_pg_array)] to fix.

Changed

Fixed

  • [#2553]: Implement Clone for PoolOptions manually (#2548) [@alilleybrinker]
  • [#2580]: Update README.md now that 0.7.0 is no longer in alpha [@saolof]
  • [#2585]: Fix for Issue #2549 - cannot use feature "rust_decimal" without also using "bigdecimal" [@deneut]
  • [#2586]: Fix optional dependency on sqlx-macros [@kitterion]
  • [#2593]: Correct mention of the tls-native-tls in the documentation. [@denschub]
  • [#2599]: Remove incorrect CAST in test database cleanup for MySQL. [@fd]
  • [#2613]: Fix readme.md to reduce confusion about optional features (decimal->rust_decimal) [@vabka]
  • [#2620]: fix(sqlite/any): encode bool as integer [@saiintbrisson]

0.7.0 - 2023-06-30

At least 70 pull requests were merged this release cycle! (The exact count is muddied with pull requests for alpha releases and such.) And we gained 43 new contributors! Thank you to everyone who helped make this release a reality.

Breaking

Many revisions were made to query analysis in the SQLite driver; these are all potentially breaking changes as they can change the output of sqlx::query!() et al. We'd like to thank [@tyrelr] for their numerous PRs to this area.

The MSSQL driver has been removed as it was not nearly at the same maturity level as the other drivers. As previously announced, we have plans to introduce a fully featured replacement as a premium offering, alongside drivers for other proprietary databases, with the goal to support full-time development on SQLx.

If interested, please email your inquiry to sqlx@launchbadge.com.

The offline mode for the queries has been changed to use a separate file per query!() invocation, which is intended to reduce the number of conflicts when merging branches in a project that both modified queries. This means that CLI flag --merged is no longer supported. See [#2363] for details and make sure that your sqlx-cli version is in sync with the sqlx version in your project.

The type ascription override syntax for the query macros has been deprecated, as parse support for it has been removed in syn 2.0, which we'll be upgrading to in the next breaking release. This can be replaced with type overrides using casting syntax (as). See [#2483] for details.

  • [#1946]: Fix compile time verification performance regression for sqlite [@liningpan]
  • [#1960]: Fix sqlite update return and order by type inference [@tyrelr]
  • [#1984]: Sqlite EXPLAIN type inference improvements [@rongcuid]
  • [#2039]: Break drivers out into separate crates, clean up some technical debt [@abonander]
    • All deprecated items have been removed.
    • The mssql feature and associated database driver has been deleted from the source tree. It will return as part of our planned SQLx Pro offering as a from-scratch rewrite with extra features (such as TLS) and type integrations that were previously missing.
    • The runtime-actix-* features have been deleted. They were previously changed to be aliases of their runtime-tokio-* counterparts for backwards compatibility reasons, but their continued existence is misleading as SQLx has no special knowledge of Actix anymore.
      • To fix, simply replace the runtime-actix-* feature with its runtime-tokio-* equivalent.
    • The git2 feature has been removed. This was a requested integration from a while ago that over time made less and less sense to be part of SQLx itself. We have to be careful with the crates we add to our public API as each one introduces yet another semver hazard. The expected replacement is to make #[derive(sqlx::Type)] useful enough that users can write wrapper types for whatever they want to use without SQLx needing to be specifically aware of it.
    • The Executor impls for Transaction and PoolConnection have been deleted because they cannot exist in the new crate architecture without rewriting the Executor trait entirely.
      • To fix this breakage, simply add a dereference where an impl Executor is expected, as they both dereference to the inner connection type which will still implement it:
        • &mut transaction -> &mut *transaction
        • &mut connection -> &mut *connection
      • These cannot be blanket impls as it triggers an overflow in the compiler due to the lack of lazy normalization, and the driver crates cannot provide their own impls due to the orphan rule.
      • We're expecting to do another major refactor of traits to incorporate generic associated types (GAT). This will mean another major release of SQLx but ideally most API usage will not need to change significantly, if at all.
    • The fields of Migrator are now #[doc(hidden)] and semver-exempt; they weren't meant to be public.
    • The offline feature has been removed from the sqlx facade crate and is enabled unconditionally as most users are expected to have enabled it anyway and disabling it doesn't seem to appreciably affect compile times.
    • The decimal feature has been renamed to rust_decimal to match the crate it actually provides integrations for.
    • AnyDriver and AnyConnection now require either sqlx::any::install_drivers() or sqlx::any::install_default_drivers() to be called at some point during the process' lifetime before the first connection is made, as the set of possible drivers is now determined at runtime. This was determined to be the least painful way to provide knowledge of database drivers to Any without them being hardcoded.
    • The AnyEncode trait has been removed.
  • [#2109]: feat: better database errors [@saiintbrisson]
  • [#2094]: Update libsqlite3-sys to 0.25.1 [@penberg]
    • Alongside this upgrade, we are now considering the linkage to libsqlite3-sys to be semver-exempt, and we reserve the right to upgrade it as necessary. If you are using libsqlite3-sys directly or a crate that links it such as rusqlite, you should pin the versions of both crates to avoid breakages from cargo update:
[dependencies]
sqlx = { version = "=0.7.0", features = ["sqlite"] }
rusqlite = "=0.29.0"
  • [#2132]: fix: use owned Builder pattern for ConnectOptions [@ar3s3ru]
  • [#2253]: Sqlite describe fixes [@tyrelr]
  • [#2285]: time: Assume UTC when decoding a DATETIME column in sqlite [@nstinus]
  • [#2363]: [offline] Change prepare to one-file-per-query [@cycraig]
  • [#2387]: PATCH: bump libsqlite3-sys to patched version [@grantkee]
  • [#2409]: fix(#2407): respect the HaltIfNull opcode when determining nullability [@arlyon]
  • [#2459]: limit the number of instructions that can be evaluated [@tyrelr]
  • [#2467]: Add and improve sqlite describe performance benchmarks [@tyrelr]
  • [#2491]: sqlite date macro support [@Arcayr]
    • Changes OffsetDateTime to be the first type used when deserializing a timestamp type.
  • [#2496]: Bump to libsqlite3-sys 0.26 [@mdecimus]
  • [#2508]: Sqlite analytical [@tyrelr]

Added

Changed

Fixed

0.6.3 - 2023-03-21

This is a hotfix to address the breakage caused by transitive dependencies upgrading to syn = "2".

We set default-features = false for our dependency on syn = "1" to be good crates.io citizens, but failed to enable the features we actually used, which went undetected because we transitively depended on syn with the default features enabled through other crates, and so they were also on for us because features are additive.

When those other dependencies upgraded to syn = "2" it was no longer enabling those features for us, and so compilation broke for projects that don't also depend on syn = "1", transitively or otherwise.

There is no PR for this fix as there was no longer a dedicated development branch for 0.6, but discussion can be found in issue #2418.

As of this release, the 0.7 release is in alpha and so development is no longer occurring against 0.6. This fix will be forward-ported to 0.7.

0.6.2 - 2022-09-14

25 pull requests were merged this release cycle.

Added

  • [#1081]: Add try_from attribute for FromRow derive [@zzhengzhuo]
    • Exemplifies "out of sight, out of mind." It's surprisingly easy to forget about PRs when they get pushed onto the second page. We'll be sure to clean out the backlog for 0.7.0.
  • [#2014]: Support additional SQLCipher options in SQLite driver. [@szymek156]
  • [#2052]: Add issue templates [@abonander]
  • [#2053]: Add documentation for IpAddr support in Postgres [@rakshith-ravi]
  • [#2062]: Add extension support for SQLite [@bradfier]
  • [#2063]: customizable db locking during migration [@fuzzbuck]

Changed

Fixed

  • [#1991]: Ensure migration progress is not lost for Postgres, MySQL and SQLite. [@crepererum]
  • [#2023]: Fix expansion of #[sqlx(flatten)] for FromRow derive [@RustyYato]
  • [#2028]: Use fully qualified path when forwarding to #[test] from #[sqlx::test] [@alexander-jackson]
  • [#2040]: Fix typo in FromRow docs [@zlidner]
  • [#2046]: added flag for PIPES_AS_CONCAT connection setting for MySQL to fix #2034 [@marcustut]
  • [#2055]: Use unlock notify also on sqlite3_exec [@madadam]
  • [#2057]: Make begin,commit,rollback cancel-safe in sqlite [@madadam]
  • [#2058]: fix typo in documentation [@lovasoa]
  • [#2067]: fix(docs): close code block in query_builder.rs [@abonander]
  • [#2069]: Fix prepare race condition in workspaces [@cycraig]\
    • NOTE: this changes the directory structure under target/ that cargo sqlx prepare depends on. If you use offline mode in your workflow, please rerun cargo install sqlx-cli to upgrade.
  • [#2072]: SqliteConnectOptions typo [@fasterthanlime]
  • [#2074]: fix: mssql uses unsigned for tinyint instead of signed [@he4d]
  • [#2081]: close unnamed portal after each executed extended query [@DXist]
  • [#2086]: PgHasArrayType for transparent types fix. [@Wopple]
    • NOTE: this is a breaking change and has been postponed to 0.7.0.
  • [#2089]: fix: Remove default chrono dep on time for sqlx-cli [@TravisWhitehead]
  • [#2091]: Sqlite explain plan log efficiency [@tyrelr]

0.6.1 - 2022-08-02

33 pull requests were merged this release cycle.

Added

  • [#1495]: Add example for manual implementation of the FromRow trait [@Erik1000]
  • [#1822]: (Postgres) Add support for std::net::IpAddr [@meh]
    • Decoding returns an error if the INET value in Postgres is a prefix and not a full address (/32 for IPv4, /128 for IPv6).
  • [#1865]: Add SQLite support for the time crate [@johnbcodes]
  • [#1902]: Add an example of how to use QueryBuilder::separated() [@sbeckeriv]
  • [#1917]: Added docs for sqlx::types::Json [@jayy-lmao]
  • [#1919]: Implement Clone for PoolOptions [@Thomasdezeeuw]
  • [#1953]: Support Rust arrays in Postgres [@e00E]
  • [#1954]: Add push_tuples for QueryBuilder [@0xdeafbeef]
  • [#1959]: Support #[sqlx(flatten)] attribute in FromRow [@TheoOiry]
  • [#1967]: Add example with external query files [@JoeyMckenzie]
  • [#1985]: Add query_builder::Separated::push_bind_unseparated() [@0xdeafbeef]
  • [#2001]: Implement #[sqlx::test] for general use
    • Includes automatic database management, migration and fixture application.
    • Drops support for end-of-lifed database versions, see PR for details.
  • [#2005]: QueryBuilder improvements [@abonander]
    • Raw SQL getters, new method to build QueryAs instead of Query.
  • [#2013]: (SQLite) Allow VFS to be set as URL query parameter [@liningpan]

Changed

Fixed

0.6.0 - 2022-06-16

This release marks the end of the 0.5.x series of releases and contains a number of breaking changes, mainly to do with backwards-incompatible dependency upgrades.

As we foresee many more of these in the future, we surveyed the community on how to handle this; the consensus appears to be "just release breaking changes more often."

As such, we expect the 0.6.x release series to be a shorter one.

39 pull requests(!) (not counting "prepare 0.5.12 release", of course) were merged this release cycle.

Breaking

  • [#1384]: (Postgres) Move server_version_num from trait to inherent impl [@AtkinsChang]
  • [#1426]: Bump ipnetwork to 0.19 [@paolobarbolini]
  • [#1455]: Upgrade time to 0.3 [@paolobarbolini]
  • [#1505]: Upgrade rustls to 0.20 [@paolobarbolini]
    • Fortunately, future upgrades should not be breaking as webpki is no longer exposed in the API.
  • [#1529]: Upgrade bigdecimal to 0.3 [@e00E]
  • [#1602]: postgres: use Oid everywhere instead of u32 [@paolobarbolini]
    • This drops the Type, Decode, Encode impls for u32 for Postgres as it was misleading. Postgres doesn't support unsigned ints without using an extension. These impls were decoding Postgres OIDs as bare u32s without any context (and trying to bind a u32 to a query would produce an OID value in SQL). This changes that to use a newtype instead, for clarity.
  • [#1612]: Make all ConnectOptions types cloneable [@05storm26]
  • [#1618]: SQLite chrono::DateTime<FixedOffset> timezone fix [@05storm26]
    • DateTime<FixedOffset> will be stored in SQLite with the correct timezone instead of always in UTC. This was flagged as a "potentially breaking change" since it changes how dates are sent to SQLite.
  • [#1733]: Update git2 to 0.14 [@joshtriplett]
  • [#1734]: Make PgLTree::push() infallible and take PgLTreeLabel directly [@sebpuetz]
  • [#1785]: Fix Rust type for SQLite REAL [@pruthvikar]
    • Makes the macros always map a REAL column to f64 instead of f32 as SQLite uses only 64-bit floats.
  • [#1816]: Improve SQLite support for sub-queries and CTEs [@tyrelr]
    • This likely will change the generated code for some invocations sqlx::query!() with SQLite.
  • [#1821]: Update uuid crate to v1 [@paolobarbolini]
  • [#1901]: Pool fixes and breaking changes [@abonander]
    • Renamed PoolOptions::connect_timeout to acquire_timeout for clarity.
    • Changed the expected signatures for PoolOptions::after_connect, before_acquire, after_release
    • Changed the signature for Pool::close() slightly
      • Now eagerly starts the pool closing, .awaiting is only necessary if you want to ensure a graceful shutdown.
    • Deleted PoolConnection::release() which was previously deprecated in favor of PoolConnection::detach().
    • Fixed connections getting leaked even when calling .close().
  • [#1748]: Derive PgHasArrayType for #[sqlx(transparent)] types [@carols10cents]

Added

  • [#1843]: Expose some useful methods on PgValueRef [@mfreeborn]
  • [#1889]: SQLx-CLI: add --connect-timeout [@abonander]
    • Adds a default 10 second connection timeout to all commands.
  • [#1890]: Added test for mssql LoginAck [@walf443]
  • [#1891]: Added test for mssql ProtocolInfo [@walf443]
  • [#1892]: Added test for mssql ReturnValue [@walf443]
  • [#1895]: Add support for i16 to Any driver [@EthanYuan]
  • [#1897]: Expose ConnectOptions and PoolOptions on Pool and database name on PgConnectOptions [@Nukesor]

Changed

Fixed

  • [#1814]: SQLx-cli README: move Usage to the same level as Install [@tobymurray]
  • [#1815]: SQLx-cli README: reword "building in offline mode" [@tobymurray]
  • [#1818]: Trim [] from host string before passing to TcpStream [@smonv]
    • This fixes handling of database URLs with IPv6 hosts.
  • [#1842]: Fix usage of serde_json in macros [@mfreeborn]
  • [#1855]: Postgres: fix panics on unknown type OID when decoding [@demurgos]
  • [#1856]: MySQL: support COLLATE_UTF8MB4_0900_AI_CI [@scottwey]
    • Fixes the MySQL driver thinking text columns are bytestring columns when querying against a Planetscale DB.
  • [#1861]: MySQL: avoid panic when streaming packets are empty [@e-rhodes]
  • [#1863]: Fix nullability check for inner joins in Postgres [@OskarPersson]
  • [#1881]: Fix field is never read warnings on Postgres test [@walf443]
  • [#1882]: Fix unused result must be used warnings [@walf443]
  • [#1888]: Fix migration checksum comparison during sqlx migrate info [@mdtusz]
  • [#1894]: Fix typos [@kianmeng]

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 for serde_json::{Value, RawValue} [@abreis]
  • [#1736]: Derive Clone for MySqlArguments and MssqlArguments [@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 for Cow<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.
  • [#1776]: Implement close-event notification for Pool [@abonander]
    • Also fixes PgListener preventing Pool::close() from resolving.
  • [#1780]: Implement query builder [@crajcan]
  • [#1781]: Postgres: support NUMERIC[] using decimal feature [@tm-drtina]
  • [#1784]: SQLite: add FromStr, Copy, PartialEq, Eq impls for options enums [@andrewwhitehead]

Changed

Fixed

0.5.11 - 2022-02-17

20 pull requests were merged this release cycle.

Added

Changed

Fixed

Additionally, we have introduced two mitigations for the issue of the cyclic dependency on ahash:

  • We re-downgraded our version requirement on indexmap from 1.7.0 back to 1.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 of serde_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 the preserve_order feature:
    [dependencies]
    serde_json = { version = "1", features = ["preserve_order"] }
    

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

Changes

Fixes

  • [#1475]: Fix panic when converting a negative chrono::Duration to PgInterval [@yuyawk]
  • [#1483]: Fix error when decoding array of custom types from Postgres [@demurgos
  • [#1501]: Reduce indexmap version requirement to 1.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 existing RUSTFLAGS 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 PRAGMAs and overriding those set by SQLx.
  • [#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 for include_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 in async fn main().

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 using futures-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 a build.rs to watch migrations/ for changes.
    • Nightly users can try RUSTFLAGS=--cfg sqlx_macros_unstable to tell the compiler to watch migrations/ for changes instead of using a build script.
    • See the new section in the docs for sqlx::migrate!() for details.
  • [#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.

A total of 25 pull requests were merged this release cycle!

0.5.5 - 2021-05-24

  • [#1242] Fix infinite loop at compile time when using query macros [@toshokan]

0.5.4 - 2021-05-22

  • [#1235] Fix compilation with rustls from an eager update to webpki [@ETCaton]

0.5.3 - 2021-05-21

0.5.2 - 2021-04-15

PostgreSQL

  • [#1170] Remove Self: Type bounds in Encode / 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 of i16::MAX for a check against the largest number of parameters in a query [@crajcan]

  • [#1112] Add support for DOMAIN types [@demurgos]

  • [#1100] Explicitly UNLISTEN before returning connections to the pool in PgListener [@Diggsey]

SQLite

  • [#1161] Catch SQLITE_MISUSE on connection close and panic [@link2xt]

  • [#1160] Do not cast pointers to i32 (cast to usize) [@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 and try_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] Rename the DbDone types to DbQueryResult. [@jplatte]

  • [#976] Remove the Done trait. The .rows_affected() method is now available as an inherent method on PgQueryResult, MySqlQueryResult and so on. [@jplatte]

  • [#1007] Remove any::AnyType (and replace with directly implementing Type<Any>) [@jplatte]

Added

Fixes

  • [#1002] For SQLite, GROUP BY in query! 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

SQLite

PostgreSQL

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 to rename_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

PostgreSQL

  • [#781] Fix decimal conversions handling of 0.01 [@pimeys]

  • [#745] Always prefer parsing of the non-localized notice severity field [@dstoeckel]

  • [#742] Enable Vec<DateTime<Utc>> with chrono [@mrcd]

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

Added

  • [#174] Inroduce a builder to construct connections to bypass the URL 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, and after_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 to bigdecimal::BigDecimal for NUMERIC columns in MySQL and PostgreSQL [@pimeys]

  • [#181] Column names and type information is now accessible from Row via Row::columns() or Row::column(name)

PostgreSQL

  • [#197] [#271] Add initial support for INTERVAL (full support pending a time::Period type) [@dimtion]

MySQL

SQLite

  • Types are now inferred for expressions. This means its now possible to use query! and query_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 a foreign_keys(true) method available on SqliteConnectOptions which is a builder for new SQLite connections (and can be passed into PoolOptions 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, and TIME via chrono 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 to i64 instead of i32, INT4 will still resolve to i32

Removed

0.3.5 - 2020-05-06

Fixed

  • [#259] Handle percent-encoded paths for SQLite [@g-s-k]

  • [#281] Deallocate SQLite statements before closing the SQLite connection [@hasali19]

  • [#284] Fix handling of 0 for BigDecimal in PostgreSQL and MySQL [@abonander]

Added

  • [#256] Add query_unchecked! and query_file_unchecked! with similar semantics to query_as_unchecked! [@meh]

  • [#252] [#297] Derive several 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 own DATABASE_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 the bigdecimal crate [@xiaopengli89]

  • [#227] Support #[sqlx(rename = "new_name")] on struct fields within a FromRow derive [@sidred]

0.3.3 - 2020-04-01

Fixed

Changed

  • [#216] Mark Cursor, Query, QueryAs, query::Map, and Transaction 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! in MySqlCursor

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 the FromRow 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 store Rows or collect them into a collection. Query (returned from sqlx::query()) has map() which takes a function to map from the Row 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 now T: Type<Database> to mirror Encode and Decode

  • Query::fetch (returned from query()) now returns a new Cursor type. Cursor is a Stream-like type where the item type borrows into the stream (which itself borrows from connection). This means that using query().fetch() you can now stream directly from the database with zero-copy and zero-allocation.

  • Remove PgTypeInfo::with_oid and replace with PgTypeInfo::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
  • [#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 implements Executor 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 to recv().

    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 the time crate [@utter-step]
    • Enumerations ( Rust enums with a #[derive(Type)] ) [@Freax13]

Changed

  • Query (and QueryAs; returned from query(), query_as(), query!(), and query_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 implements Execute as a query. Execute is implemented for Query and QueryAs 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 fetch Rows 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 from query()) no longer has fetch_one, fetch_optional, or fetch_all. You must map the row using map() and then you will have a query::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! and query_as!. For example, where the column would resolve to String in Rust (TEXT, VARCHAR, etc.), you may now use Option<String>, Option<&str>, or &str instead. [@abonander]

  • [#108] Make unknown type errors far more informative. As an example, trying to SELECT a DATE column will now try and tell you about the chrono feature. [@abonander]

    optional feature `chrono` required for type DATE of column #1 ("now")
    

0.2.6 - 2020-03-10

Added

Fixed

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 percent-decoded before being presented to the server [@repnop]

  • [@100] Fix FLOAT and DOUBLE decoding in MySQL

Added

  • [#72] Add PgTypeInfo::with_oid to allow simple construction of PgTypeInfo which enables HasSqlType 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 and Decode. 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

  • [#57] Add support for unsigned integers and binary types in query! for MySQL [@mehcode]

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 in sqlx-macros explicitly

0.2.1 - 2020-01-16

Fixed

  • [#55] Use a shared tokio runtime for the query! macro compile-time execution (under the runtime-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 on Pool or Connection to start a new SQL transaction. This returns sqlx::Transaction which will ROLLBACK on Drop or can be explicitly COMMIT using commit().

  • Support TLS connections.

0.1.4 - 2020-01-11

Fixed

Added

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, and caching_sha2_password.

  • Chrono support for MySQL was only partially implemented (was missing NaiveTime and DateTime<Utc>).

  • Vec<u8> (and [u8]) support for MySQL (BLOB) and Postgres (BYTEA).