Skip to content

Commit

Permalink
Prepare a diesel 2.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed May 31, 2024
1 parent 48a8971 commit 3590611
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 85 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ concurrency:
jobs:
check_and_test:
name: Check
needs: [sqlite_bundled, rustfmt_and_clippy, postgres_bundled]
needs: [sqlite_bundled, rustfmt_and_clippy, postgres_bundled, mysql_bundled, typos]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -449,7 +449,7 @@ jobs:
RUSTDOCFLAGS: -Zsanitizer=address
RUSTFLAGS: -Zsanitizer=address
ASAN_OPTIONS: detect_stack_use_after_return=1
run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu
run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras __with_asan_tests" --target x86_64-unknown-linux-gnu

postgres_bundled:
name: Check postgres bundled + Postgres with asan
Expand Down Expand Up @@ -491,7 +491,7 @@ jobs:
RUSTDOCFLAGS: -Zsanitizer=address
RUSTFLAGS: -Zsanitizer=address
ASAN_OPTIONS: detect_stack_use_after_return=1
run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "postgres pq-sys pq-sys/bundled pq-src/with-asan" --target x86_64-unknown-linux-gnu
run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "postgres extras __with_asan_tests" --target x86_64-unknown-linux-gnu

mysql_bundled:
name: Check mysql bundled + Mysql with asan
Expand Down Expand Up @@ -543,7 +543,7 @@ jobs:
LSAN_OPTIONS: suppressions=/tmp/suppr.txt
run: |
echo "leak:mysql_server_init" > /tmp/suppr.txt
cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "mysql mysqlclient-sys mysqlclient-sys/bundled mysqlclient-src/with-asan" --target x86_64-unknown-linux-gnu
cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "mysql extras __with_asan_tests" --target x86_64-unknown-linux-gnu
minimal_rust_version:
name: Check Minimal supported rust version (1.78.0)
Expand Down Expand Up @@ -576,8 +576,6 @@ jobs:
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
Expand Down
64 changes: 61 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Increasing the minimal supported Rust version will always be coupled at least wi

## Unreleased

## [2.2.0] 2024-05-31

### Added

* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped.
* Support `[print_schema] exclude_custom_type_definitions = ["Vector"]`. If a `custom type` matches one element on the list it's skipped.
* Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema`
* Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions
* Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive.
Expand All @@ -23,13 +25,64 @@ Increasing the minimal supported Rust version will always be coupled at least wi
* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)).
* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating multiple schema.rs files
* Add support for `COPY TO` and `COPY FROM` statements
* Add support for mapping `chrono::Duration` to postgresql's `INTERVAL` sql type
* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to support serialization/deserialization of SQLite databases to and from byte buffers.
* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope with `sqlite3_free`.

### Changed

* The minimal officially supported rustc version is now 1.78.0
* Deprecated `sql_function!` in favour of `define_sql_function!` which provides compatibility with `#[dsl::auto_type]`
* Deserialization error messages now contain information about the field that failed to deserialize

## [2.1.6] 2024-04-19

* Fix using `BoxableExpression` with having clauses
* Fix using numeric expressions with aliased fields
* Minor documentation fixes

## [2.1.5] 2024-03-15

* Fix `impl SqlOrd` postgres > postgres_backend feature flag.
* Allow `Queryable` to be used with multiple table names.
* Fix an inconsistent unit test
* Fix a clippy lint
* Fix ./bin/test feature flag calls.
* Update `libsqlite3-sys` to allow version 0.28 as well

## [2.1.4] 2023-11-14

* Update `libsqlite3-sys` to allow version 0.27 as well

## [2.1.3] 2023-10-05

* Increased accidently decreased limit around element count in `DISTINCT ON` and `ORDER BY` clauses again as that broke existing code

## [2.1.2] 2023-09-25

## Fixed

* Fixed another potential breaking chaneg around queries containing `DISTINCT ON` and `ORDER BY` clauses consisting of custom sql expressions (e.g. `.nullable()`)
* Fixed an issue where `#[derive(Selectable)]` and `#[diesel(check_for_backend)]` generates invalid rust code if the struct contains lifetimes/generic types

## [2.1.1] 2023-08-25

## Fixed

* Fixed an issue in diesel-cli that lead to using unquoted table names in one of the internal queries
* Fixed a bug in `diesel print-schema` that lead to generating invalid `table!` macros if both the `#[sql_name]` and the `#[max_length]` attribute are present
* Fixed an issue in diesel-cli that lead to ignoring certain foreign key constraints for postgresql
* Fixed an crash while using `diesel print-schema` with really old sqlite versions
* Fixed an issue where `#[diesel(check_for_backend)]` ignored `#[diesel(deserialize_as)]` attributes
* Fixed several issues with the new `#[derive(MultiConnection)]` feature
* Fixed some edge cases in our sqlite timestamp parsing behaviour
* `diesel migration generate --diff-schema` now respects table filters as setup for `print-schema` via `diesel.toml`
* Fixed a potential breaking change around queries containing `DISTINCT ON` and `ORDER BY` clauses consisting of custom sql expressions (e.g. `diesel::dsl::sql`)

## Added

* Support for bigdecimal 0.4

## [2.1.0] 2023-05-26

### Changed
Expand All @@ -38,8 +91,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi

### Added

* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to support serialization/deserialization of SQLite databases to and from byte buffers.
* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope with `sqlite3_free`.
* Added the `custom_type_derives` config option to customize the derives for SQL
type definitions automatically generated by Diesel CLI.
* Add a `#[derive(MultiConnection)]` proc-macro that lets you easily implement `diesel::Connection`
Expand Down Expand Up @@ -2047,3 +2098,10 @@ queries or set `PIPES_AS_CONCAT` manually.
[2.0.3]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...v2.0.3
[2.0.4]: https://github.com/diesel-rs/diesel/compare/v.2.0.3...v2.0.4
[2.1.0]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.1.0
[2.1.1]: https://github.com/diesel-rs/diesel/compare/v.2.1.0...v2.1.1
[2.1.2]: https://github.com/diesel-rs/diesel/compare/v.2.1.1...v2.1.2
[2.1.3]: https://github.com/diesel-rs/diesel/compare/v.2.1.2...v2.1.3
[2.1.4]: https://github.com/diesel-rs/diesel/compare/v.2.1.3...v2.1.4
[2.1.5]: https://github.com/diesel-rs/diesel/compare/v.2.1.4...v2.1.5
[2.1.6]: https://github.com/diesel-rs/diesel/compare/v.2.1.5...v2.1.6
[2.2.0]: https://github.com/diesel-rs/diesel/compare/v.2.1.0...v2.2.0
31 changes: 20 additions & 11 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diesel"
version = "2.1.4"
version = "2.2.0"
license = "MIT OR Apache-2.0"
description = "A safe, extensible ORM and Query Builder for PostgreSQL, SQLite, and MySQL"
readme = "README.md"
Expand All @@ -11,6 +11,7 @@ keywords = ["orm", "database", "sql"]
categories = ["database"]
edition = "2021"
rust-version.workspace = true
include = ["src/**.rs", "tests/**.rs", "LICENSE-*", "README.md"]

[dependencies]
byteorder = { version = "1.0", optional = true }
Expand All @@ -20,7 +21,7 @@ libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true, features = ["
mysqlclient-sys = { version = ">=0.2.5, <0.4.0", optional = true }
mysqlclient-src = { version = "0.1.0", optional = true }
pq-sys = { version = ">=0.4.0, <0.7.0", optional = true }
pq-src = { version = "0.1", optional = true }
pq-src = { version = "0.2", optional = true }
quickcheck = { version = "1.0.3", optional = true }
serde_json = { version = ">=0.8.0, <2.0", optional = true }
url = { version = "2.1.0", optional = true }
Expand All @@ -38,7 +39,7 @@ itoa = { version = "1.0.0", optional = true }
time = { version = "0.3.9", optional = true, features = ["macros"] }

[dependencies.diesel_derives]
version = "~2.1.0"
version = "~2.2.0"
path = "../diesel_derives"

[dev-dependencies]
Expand All @@ -56,21 +57,29 @@ huge-tables = ["64-column-tables"]
32-column-tables = ["diesel_derives/32-column-tables"]
64-column-tables = ["32-column-tables", "diesel_derives/64-column-tables"]
128-column-tables = ["64-column-tables", "diesel_derives/128-column-tables"]
postgres = ["pq-sys", "postgres_backend"]
sqlite = ["libsqlite3-sys", "diesel_derives/sqlite", "time?/formatting", "time?/parsing"]
mysql = ["mysqlclient-sys", "url", "percent-encoding", "bitflags", "mysql_backend"]
postgres = ["dep:pq-sys", "postgres_backend"]
sqlite = ["dep:libsqlite3-sys", "diesel_derives/sqlite", "time?/formatting", "time?/parsing"]
mysql = ["dep:mysqlclient-sys", "dep:url", "dep:percent-encoding", "dep:bitflags", "mysql_backend"]
without-deprecated = ["diesel_derives/without-deprecated"]
with-deprecated = ["diesel_derives/with-deprecated"]
network-address = ["ipnetwork", "libc"]
ipnet-address = ["ipnet", "libc"]
numeric = ["num-bigint", "bigdecimal", "num-traits", "num-integer"]
postgres_backend = ["diesel_derives/postgres", "bitflags", "byteorder", "itoa"]
mysql_backend = ["diesel_derives/mysql", "byteorder"]
network-address = ["dep:ipnetwork", "dep:libc"]
ipnet-address = ["dep:ipnet", "dep:libc"]
numeric = ["dep:num-bigint", "dep:bigdecimal", "dep:num-traits", "dep:num-integer"]
postgres_backend = ["diesel_derives/postgres", "dep:bitflags", "dep:byteorder", "dep:itoa"]
mysql_backend = ["diesel_derives/mysql", "dep:byteorder"]
returning_clauses_for_sqlite_3_35 = []
i-implement-a-third-party-backend-and-opt-into-breaking-changes = []
r2d2 = ["diesel_derives/r2d2", "dep:r2d2"]
chrono = ["diesel_derives/chrono", "dep:chrono"]
time = ["diesel_derives/time", "dep:time"]
__with_asan_tests = [
"libsqlite3-sys?/bundled",
"libsqlite3-sys?/with-asan",
"pq-sys?/bundled",
"pq-src?/with-asan",
"mysqlclient-sys?/bundled",
"mysqlclient-src?/with-asan",
]

[package.metadata.docs.rs]
features = ["postgres", "mysql", "sqlite", "extras"]
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/functions/aggregate_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define_sql_function! {
/// ```rust
/// # include!("../../doctest_setup.rs");
/// # use diesel::dsl::*;
/// # #[cfg(feature = "bigdecimal")]
/// # #[cfg(feature = "numeric")]
/// # extern crate bigdecimal;
/// #
/// # fn main() {
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ mod tests {
use crate::mysql::connection::stmt::Statement;
use crate::prelude::*;
use crate::sql_types::*;
#[cfg(feature = "bigdecimal")]
#[cfg(feature = "numeric")]
use std::str::FromStr;

fn to_value<ST, T>(
Expand Down
6 changes: 3 additions & 3 deletions diesel/src/mysql/types/numeric.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "bigdecimal")]
#[cfg(feature = "numeric")]
mod bigdecimal {
use bigdecimal::{BigDecimal, FromPrimitive};
use std::io::prelude::*;
Expand All @@ -8,7 +8,7 @@ mod bigdecimal {
use crate::serialize::{self, IsNull, Output, ToSql};
use crate::sql_types::Numeric;

#[cfg(all(feature = "mysql_backend", feature = "bigdecimal"))]
#[cfg(all(feature = "mysql_backend", feature = "numeric"))]
impl ToSql<Numeric, Mysql> for BigDecimal {
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
write!(out, "{}", *self)
Expand All @@ -17,7 +17,7 @@ mod bigdecimal {
}
}

#[cfg(all(feature = "mysql_backend", feature = "bigdecimal"))]
#[cfg(all(feature = "mysql_backend", feature = "numeric"))]
impl FromSql<Numeric, Mysql> for BigDecimal {
fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
match value.numeric_value()? {
Expand Down
62 changes: 46 additions & 16 deletions diesel/src/pg/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,35 @@ pub mod sql_types {
///
/// ### [`ToSql`] impls
///
#[cfg_attr(feature = "ipnetwork", doc = " - [`ipnetwork::IpNetwork`][IpNetwork]")]
#[cfg_attr(feature = "ipnet", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(not(any(feature = "ipnetwork", feature = "ipnet")), doc = "N/A")]
#[cfg_attr(
feature = "network-address",
doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
)]
#[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(
not(any(feature = "network-address", feature = "ipnet-address")),
doc = "N/A"
)]
///
/// ### [`FromSql`] impls
///
#[cfg_attr(feature = "ipnetwork", doc = " - [`ipnetwork::IpNetwork`][IpNetwork]")]
#[cfg_attr(feature = "ipnet", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(not(any(feature = "ipnetwork", feature = "ipnet")), doc = "N/A")]
#[cfg_attr(
feature = "network-address",
doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
)]
#[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(
not(any(feature = "network-address", feature = "ipnet-address")),
doc = "N/A"
)]
///
/// [`ToSql`]: crate::serialize::ToSql
/// [`FromSql`]: crate::deserialize::FromSql
#[cfg_attr(feature = "ipnetwork", doc = " [IpNetwork]: ipnetwork::IpNetwork")]
#[cfg_attr(feature = "ipnet", doc = " [IpNet]: ipnet::IpNet")]
#[cfg_attr(
feature = "network-address",
doc = " [IpNetwork]: ipnetwork::IpNetwork"
)]
#[cfg_attr(feature = "ipnet-address", doc = " [IpNet]: ipnet::IpNet")]
///
/// # Examples
///
Expand Down Expand Up @@ -487,20 +502,35 @@ pub mod sql_types {
///
/// ### [`ToSql`] impls
///
#[cfg_attr(feature = "ipnetwork", doc = " - [`ipnetwork::IpNetwork`][IpNetwork]")]
#[cfg_attr(feature = "ipnet", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(not(any(feature = "ipnetwork", feature = "ipnet")), doc = "N/A")]
#[cfg_attr(
feature = "network-address",
doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
)]
#[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(
not(any(feature = "network-address", feature = "ipnet-address")),
doc = "N/A"
)]
///
/// ### [`FromSql`] impls
///
#[cfg_attr(feature = "ipnetwork", doc = " - [`ipnetwork::IpNetwork`][IpNetwork]")]
#[cfg_attr(feature = "ipnet", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(not(any(feature = "ipnetwork", feature = "ipnet")), doc = "N/A")]
#[cfg_attr(
feature = "network-address",
doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
)]
#[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
#[cfg_attr(
not(any(feature = "network-address", feature = "ipnet-address")),
doc = "N/A"
)]
///
/// [`ToSql`]: crate::serialize::ToSql
/// [`FromSql`]: crate::deserialize::FromSql
#[cfg_attr(feature = "ipnetwork", doc = " [IpNetwork]: ipnetwork::IpNetwork")]
#[cfg_attr(feature = "ipnet", doc = " [IpNet]: ipnet::IpNet")]
#[cfg_attr(
feature = "network-address",
doc = " [IpNetwork]: ipnetwork::IpNetwork"
)]
#[cfg_attr(feature = "ipnet-address", doc = " [IpNet]: ipnet::IpNet")]
///
/// # Examples
///
Expand Down
Loading

0 comments on commit 3590611

Please sign in to comment.