diff --git a/CHANGELOG.md b/CHANGELOG.md index c6286ef405..351ac757f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.5.8 - 2021-10-01 + +[A total of 24 pull requests][0.5.8-prs] 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. +* [[#1345]] Initial support for Postgres `COPY FROM/TO`[[@montanalow], [@abonander]] +* [[#1439]] Handle multiple waiting results correctly in MySQL [[@eagletmt]] + +[#1289]: https://github.com/launchbadge/sqlx/pull/1289 +[#1295]: https://github.com/launchbadge/sqlx/pull/1295 +[#1345]: https://github.com/launchbadge/sqlx/pull/1345 +[#1439]: https://github.com/launchbadge/sqlx/pull/1439 +[0.5.8-prs]: https://github.com/launchbadge/sqlx/pulls?q=is%3Apr+is%3Amerged+merged%3A2021-08-21..2021-10-01 + ## 0.5.7 - 2021-08-20 * [[#1392]] use `resolve_path` when getting path for `include_str!()` [[@abonander]] @@ -967,4 +983,8 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg [@marshoepial]: https://github.com/marshoepial [@link2ext]: https://github.com/link2ext [@madadam]: https://github.com/madadam -[@AtkinsChang]: https://github.com/AtkinsChang \ No newline at end of file +[@AtkinsChang]: https://github.com/AtkinsChang +[@djmarcin]: https://github.com/djmarcin +[@ghassmo]: https://github.com/ghassmo +[@eagletmt]: https://github.com/eagletmt +[@montanalow]: https://github.com/montanalow \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 6e6cae9b84..b1bb6f1475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2333,7 +2333,7 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.5.7" +version = "0.5.8" dependencies = [ "anyhow", "async-std", @@ -2366,7 +2366,7 @@ dependencies = [ [[package]] name = "sqlx-cli" -version = "0.5.7" +version = "0.5.8" dependencies = [ "anyhow", "async-trait", @@ -2389,7 +2389,7 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.5.7" +version = "0.5.8" dependencies = [ "ahash", "atoi", @@ -2526,7 +2526,7 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.5.7" +version = "0.5.8" dependencies = [ "dotenv", "either", @@ -2546,7 +2546,7 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.5.7" +version = "0.5.8" dependencies = [ "actix-rt", "async-native-tls", diff --git a/Cargo.toml b/Cargo.toml index 00ef4defb7..3187bdfdd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ [package] name = "sqlx" -version = "0.5.7" +version = "0.5.8" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/launchbadge/sqlx" diff --git a/sqlx-cli/Cargo.toml b/sqlx-cli/Cargo.toml index bd30af14ab..14bf87d0d6 100644 --- a/sqlx-cli/Cargo.toml +++ b/sqlx-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-cli" -version = "0.5.7" +version = "0.5.8" description = "Command-line utility for SQLx, the Rust SQL toolkit." edition = "2018" readme = "README.md" diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index c58de1ea39..27b078d3e2 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-core" -version = "0.5.7" +version = "0.5.8" repository = "https://github.com/launchbadge/sqlx" description = "Core of SQLx, the rust SQL toolkit. Not intended to be used directly." license = "MIT OR Apache-2.0" diff --git a/sqlx-core/src/any/migrate.rs b/sqlx-core/src/any/migrate.rs index 1825ff939b..04fa659b74 100644 --- a/sqlx-core/src/any/migrate.rs +++ b/sqlx-core/src/any/migrate.rs @@ -223,7 +223,10 @@ impl Migrate for AnyConnection { AnyConnectionKind::MySql(conn) => conn.revert(migration), #[cfg(feature = "mssql")] - AnyConnectionKind::Mssql(_conn) => unimplemented!(), + AnyConnectionKind::Mssql(_conn) => { + let _ = migration; + unimplemented!() + } } } } diff --git a/sqlx-core/src/postgres/copy.rs b/sqlx-core/src/postgres/copy.rs index 0d8eb46f2d..18771e3e53 100644 --- a/sqlx-core/src/postgres/copy.rs +++ b/sqlx-core/src/postgres/copy.rs @@ -138,9 +138,32 @@ impl> PgCopyIn { }) } + /// Returns `true` if Postgres is expecting data in text or CSV format. + pub fn is_textual(&self) -> bool { + self.response.format == 0 + } + + /// Returns the number of columns expected in the input. + pub fn num_columns(&self) -> usize { + assert_eq!( + self.response.num_columns as usize, + self.response.format_codes.len(), + "num_columns does not match format_codes.len()" + ); + self.response.format_codes.len() + } + + /// Check if a column is expecting data in text format (`true`) or binary format (`false`). + /// + /// ### Panics + /// If `column` is out of range according to [`.num_columns()`][Self::num_columns]. + pub fn column_is_textual(&self, column: usize) -> bool { + self.response.format_codes[column] == 0 + } + /// Send a chunk of `COPY` data. /// - /// If you're copying data from an `AsyncRead`, maybe consider [Self::copy_from] instead. + /// If you're copying data from an `AsyncRead`, maybe consider [Self::read_from] instead. pub async fn send(&mut self, data: impl Deref) -> Result<&mut Self> { self.conn .as_deref_mut() diff --git a/sqlx-core/src/postgres/types/decimal.rs b/sqlx-core/src/postgres/types/decimal.rs index e206b86b04..61ca06fcb7 100644 --- a/sqlx-core/src/postgres/types/decimal.rs +++ b/sqlx-core/src/postgres/types/decimal.rs @@ -88,7 +88,8 @@ impl TryFrom<&'_ Decimal> for PgNumeric { type Error = BoxDynError; fn try_from(decimal: &Decimal) -> Result { - if decimal.is_zero() { + // `Decimal` added `is_zero()` as an inherent method in a more recent version + if Zero::is_zero(decimal) { return Ok(PgNumeric::Number { sign: PgNumericSign::Positive, scale: 0, diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index fd6206ad51..fcfd09805e 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-macros" -version = "0.5.7" +version = "0.5.8" repository = "https://github.com/launchbadge/sqlx" description = "Macros for SQLx, the rust SQL toolkit. Not intended to be used directly." license = "MIT OR Apache-2.0" diff --git a/sqlx-rt/Cargo.toml b/sqlx-rt/Cargo.toml index a0db271926..2e4073c52f 100644 --- a/sqlx-rt/Cargo.toml +++ b/sqlx-rt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-rt" -version = "0.5.7" +version = "0.5.8" repository = "https://github.com/launchbadge/sqlx" license = "MIT OR Apache-2.0" description = "Runtime abstraction used by SQLx, the Rust SQL toolkit. Not intended to be used directly." diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index 9264ae21aa..51dfbc6d37 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -1148,7 +1148,7 @@ async fn it_can_abort_copy_in() -> anyhow::Result<()> { ) .await?; - let mut copy = conn + let copy = conn .copy_in_raw( r#" COPY users (id) FROM STDIN WITH (FORMAT CSV, HEADER); @@ -1201,6 +1201,7 @@ async fn it_can_copy_out() -> anyhow::Result<()> { Ok(()) } +#[sqlx_macros::test] async fn test_issue_1254() -> anyhow::Result<()> { #[derive(sqlx::Type)] #[sqlx(type_name = "pair")] diff --git a/tests/sqlite/derives.rs b/tests/sqlite/derives.rs index bbbc3d673d..d91e012b30 100644 --- a/tests/sqlite/derives.rs +++ b/tests/sqlite/derives.rs @@ -1,5 +1,5 @@ use sqlx::Sqlite; -use sqlx_test::{new, test_type}; +use sqlx_test::test_type; #[derive(Debug, PartialEq, sqlx::Type)] #[repr(u32)]