Skip to content

Commit

Permalink
Merge pull request #3959 from 1Dragoon/backports/2.1.4
Browse files Browse the repository at this point in the history
Backports/2.1.4
  • Loading branch information
weiznich authored Mar 15, 2024
2 parents ba2f567 + 2c9f46d commit c96c870
Show file tree
Hide file tree
Showing 36 changed files with 123 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ jobs:
- name: Test diesel-derives (nightly)
if: matrix.rust == 'nightly'
shell: bash
run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} diesel/unstable diesel/time time diesel/chrono chrono"
run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} diesel/unstable diesel/time time diesel/chrono chrono ${{ matrix.backend }}"

- name: Test diesel-derives
shell: bash
run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }}"
run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} ${{ matrix.backend }}"

- name: Test diesel-cli
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Publish documentation
if: success()
uses: JamesIves/github-pages-deploy-action@v4.2.5
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
Expand Down
49 changes: 30 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
All user visible changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/), as described
for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md)
For any named minimal supported Rust version we guarantee that it is possible to build Diesel with the
default features enabled using some set of dependencies. Those set of dependencies is not necessarily
an up to date version of the specific dependency. We check this by using the unstable `-Z minimal-version` cargo flag.
For any named minimal supported Rust version we guarantee that it is possible to build Diesel with the
default features enabled using some set of dependencies. Those set of dependencies is not necessarily
an up to date version of the specific dependency. We check this by using the unstable `-Z minimal-version` cargo flag.
Increasing the minimal supported Rust version will always be coupled at least with a minor release.

## Unreleased

## [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
Expand All @@ -23,7 +32,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi
## 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
* 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

Expand All @@ -36,22 +45,23 @@ Increasing the minimal supported Rust version will always be coupled at least wi
* 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`
* `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
## Added

* Support for bigdecimal 0.4


## [2.1.0] 2023-05-26

### Changed
### Changed

* The minimal officially supported rustc version is now 1.65.0

### 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 @@ -280,7 +290,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi
and a bound to `QueryableByName<DB>` with `FromSqlRow<Untyped, DB>`.

* CLI flags of `only-tables` and `except-tables` are now interpreted as regular expressions.
Similarly, `only_tabels` and `except_tables` in `diesel.toml` are treated as regular expressions.
Similarly, `only_tables` and `except_tables` in `diesel.toml` are treated as regular expressions.

* Now you can sort column fields by name with the `column-sorting` option.
It can be set to either `ordinal_position` (default) or `name`.
Expand Down Expand Up @@ -2052,14 +2062,15 @@ queries or set `PIPES_AS_CONCAT` manually.
[1.4.8]: https://github.com/diesel-rs/diesel/compare/v1.4.7...v1.4.8
[2.0.0 Rc0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0-rc0
[2.0.0 Rc1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0-rc0...v2.0.0-rc1
[2.0.0]: https://github.com/diesel-rs/diesel/compare/v1.4.0...v2.0.0
[2.0.1]: https://github.com/diesel-rs/diesel/compare/v2.0.0...v2.0.1
[2.0.2]: https://github.com/diesel-rs/diesel/compare/v2.0.1...v2.0.2
[2.0.0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0
[2.0.1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.0.1
[2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.1...v2.0.2
[diesel_derives 2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...diesel_derives_v2.0.2
[2.0.3]: https://github.com/diesel-rs/diesel/compare/v2.0.2...v2.0.3
[2.0.4]: https://github.com/diesel-rs/diesel/compare/v2.0.3...v2.0.4
[2.1.0]: https://github.com/diesel-rs/diesel/compare/v2.0.0...v2.1.0
[2.1.1]: https://github.com/diesel-rs/diesel/compare/v2.1.0...v2.1.1
[2.1.2]: https://github.com/diesel-rs/diesel/compare/v2.1.1...v2.1.2
[2.1.3]: https://github.com/diesel-rs/diesel/compare/v2.1.2...v2.1.3
[2.1.4]: https://github.com/diesel-rs/diesel/compare/v2.1.3...v2.1.4
[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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"diesel",
"diesel_cli",
Expand Down
6 changes: 3 additions & 3 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ else
(cd diesel_cli && cargo test --features "sqlite" --no-default-features "$*")
(cd diesel_migrations && cargo test --features "sqlite diesel/sqlite" "$*")
(cd diesel_migrations && cargo test --features "sqlite diesel/sqlite" "$*")
(cd diesel_derives && cargo test --features "diesel/sqlite" "$*")
(cd diesel_derives && cargo test --features "sqlite diesel/sqlite" "$*")
(cd diesel_tests && cargo test --features "sqlite" --no-default-features "$*")
(cd diesel_dynamic_schema && cargo test --features "sqlite diesel/sqlite" "$*")
(cd diesel_bench && cargo test --features "sqlite" --benches "$*")

(cd diesel_migrations && cargo test --features "postgres diesel/postgres" "$*")
(cd diesel_migrations/migrations_macros && cargo test --features "diesel/postgres postgres" "$*")
(cd diesel_derives && cargo test --features "diesel/postgres" "$*")
(cd diesel_derives && cargo test --features "postgres diesel/postgres" "$*")
(cd diesel_cli && cargo test --features "postgres" --no-default-features "$*")
(cd diesel_tests && cargo test --features "postgres" --no-default-features "$*")
(cd diesel_dynamic_schema && cargo test --features "postgres diesel/postgres" "$*")
(cd diesel_bench && cargo test --features "postgres" --benches "$*")

(cd diesel_migrations && cargo test --features "mysql diesel/mysql" "$*" -- --test-threads 1)
(cd diesel_migrations/migrations_macros && cargo test --features "diesel/mysql mysql" "$*" -- --test-threads 1)
(cd diesel_derives && cargo test --features "diesel/mysql" "$*" -- --test-threads 1)
(cd diesel_derives && cargo test --features "mysql diesel/mysql" "$*" -- --test-threads 1)
(cd diesel_cli && cargo test --features "mysql" --no-default-features "$*" -- --test-threads 1)
(cd diesel_tests && cargo test --features "mysql" --no-default-features "$*" -- --test-threads 1)
(cd diesel_dynamic_schema && cargo test --features "mysql diesel/mysql" "$*" -- --test-threads 1)
Expand Down
4 changes: 2 additions & 2 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.1.5"
license = "MIT OR Apache-2.0"
description = "A safe, extensible ORM and Query Builder for PostgreSQL, SQLite, and MySQL"
readme = "README.md"
Expand All @@ -16,7 +16,7 @@ rust-version = "1.65.0"
byteorder = { version = "1.0", optional = true }
chrono = { version = "0.4.20", optional = true, default-features = false, features = ["clock", "std"] }
libc = { version = "0.2.0", optional = true }
libsqlite3-sys = { version = ">=0.17.2, <0.28.0", optional = true, features = ["bundled_bindings"] }
libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true, features = ["bundled_bindings"] }
mysqlclient-sys = { version = "0.2.5", optional = true }
pq-sys = { version = "0.4.0", optional = true }
quickcheck = { version = "1.0.3", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ where
/// If the transaction fails to commit due to a `SerializationFailure` or a
/// `ReadOnlyTransaction` a rollback will be attempted.
/// If the rollback fails, the error will be returned in a
/// [`Error::RollbackErrorOnCommit`](crate::result::Error::RollbackErrorOnCommit),
/// [`Error::RollbackErrorOnCommit`],
/// from which you will be able to extract both the original commit error and
/// the rollback error.
/// In addition, the connection will be considered broken
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/connection/statement_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ where

/// Wraps a possibly cached prepared statement
///
/// Essentially a customized version of [`Cow`](std::borrow::Cow)
/// that does not depend on [`ToOwned`](std::borrow::ToOwned)
/// Essentially a customized version of [`Cow`]
/// that does not depend on [`ToOwned`]
#[allow(missing_debug_implementations, unreachable_pub)]
#[cfg_attr(
doc_cfg,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
//! `64-column-tables` feature. Enabling this feature will increase your compile times significantly.
//! - `i-implement-a-third-party-backend-and-opt-into-breaking-changes`: This feature opens up some otherwise
//! private API, that can be useful to implement a third party [`Backend`](crate::backend::Backend)
//! or write a custom [`Connection`](crate::connection::Connection) implementation. **Do not use this feature for
//! or write a custom [`Connection`] implementation. **Do not use this feature for
//! any other usecase**. By enabling this feature you explicitly opt out diesel stability guarantees. We explicitly
//! reserve us the right to break API's exported under this feature flag in any upcoming minor version release.
//! If you publish a crate depending on this feature flag consider to restrict the supported diesel version to the
Expand Down
5 changes: 3 additions & 2 deletions diesel/src/mysql/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl ToSql<Timestamp, Mysql> for NaiveDateTime {
hour: self.hour() as libc::c_uint,
minute: self.minute() as libc::c_uint,
second: self.second() as libc::c_uint,
#[allow(deprecated)] // otherwise we would need to bump our minimal chrono version
second_part: libc::c_ulong::from(self.timestamp_subsec_micros()),
neg: false,
time_type: MysqlTimestampType::MYSQL_TIMESTAMP_DATETIME,
Expand Down Expand Up @@ -162,11 +163,11 @@ mod tests {
#[test]
fn times_relative_to_now_encode_correctly() {
let connection = &mut connection();
let time = Utc::now().naive_utc() + Duration::days(1);
let time = Utc::now().naive_utc() + Duration::try_days(1).unwrap();
let query = select(now.lt(time));
assert!(query.get_result::<bool>(connection).unwrap());

let time = Utc::now().naive_utc() - Duration::days(1);
let time = Utc::now().naive_utc() - Duration::try_days(1).unwrap();
let query = select(now.gt(time));
assert!(query.get_result::<bool>(connection).unwrap());
}
Expand Down
16 changes: 9 additions & 7 deletions diesel/src/pg/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ impl ToSql<Date, Pg> for NaiveDate {
impl FromSql<Date, Pg> for NaiveDate {
fn from_sql(bytes: PgValue<'_>) -> deserialize::Result<Self> {
let PgDate(offset) = FromSql::<Date, Pg>::from_sql(bytes)?;
match pg_epoch_date().checked_add_signed(Duration::days(i64::from(offset))) {
#[allow(deprecated)] // otherwise we would need to bump our minimal chrono version
let duration = Duration::days(i64::from(offset));
match pg_epoch_date().checked_add_signed(duration) {
Some(date) => Ok(date),
None => {
let error_message = format!(
Expand Down Expand Up @@ -205,11 +207,11 @@ mod tests {
#[test]
fn times_relative_to_now_encode_correctly() {
let connection = &mut connection();
let time = Utc::now().naive_utc() + Duration::seconds(60);
let time = Utc::now().naive_utc() + Duration::try_seconds(60).unwrap();
let query = select(now.at_time_zone("utc").lt(time));
assert!(query.get_result::<bool>(connection).unwrap());

let time = Utc::now().naive_utc() - Duration::seconds(60);
let time = Utc::now().naive_utc() - Duration::try_seconds(60).unwrap();
let query = select(now.at_time_zone("utc").gt(time));
assert!(query.get_result::<bool>(connection).unwrap());
}
Expand Down Expand Up @@ -280,8 +282,8 @@ mod tests {
let query = select(sql::<Date>("'J0'::date").eq(julian_epoch));
assert!(query.get_result::<bool>(connection).unwrap());

let max_date = NaiveDate::MAX;
let query = select(sql::<Date>("'262143-12-31'::date").eq(max_date));
let max_date = NaiveDate::from_ymd_opt(262142, 12, 31).unwrap();
let query = select(sql::<Date>("'262142-12-31'::date").eq(max_date));
assert!(query.get_result::<bool>(connection).unwrap());

let january_first_2018 = NaiveDate::from_ymd_opt(2018, 1, 1).unwrap();
Expand Down Expand Up @@ -311,8 +313,8 @@ mod tests {
let query = select(sql::<Date>("'J0'::date"));
assert_eq!(Ok(julian_epoch), query.get_result::<NaiveDate>(connection));

let max_date = NaiveDate::MAX;
let query = select(sql::<Date>("'262143-12-31'::date"));
let max_date = NaiveDate::from_ymd_opt(262142, 12, 31).unwrap();
let query = select(sql::<Date>("'262142-12-31'::date"));
assert_eq!(Ok(max_date), query.get_result::<NaiveDate>(connection));

let january_first_2018 = NaiveDate::from_ymd_opt(2018, 1, 1).unwrap();
Expand Down
8 changes: 6 additions & 2 deletions diesel/src/pg/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ impl ToSql<sql_types::Jsonb, Pg> for serde_json::Value {
}
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use crate::query_builder::bind_types::ByteWrapper;
use crate::deserialize::FromSql;
use crate::pg::{Pg, PgValue};
use crate::query_builder::bind_collector::ByteWrapper;
use crate::serialize::{Output, ToSql};
use crate::sql_types;

#[test]
fn json_to_sql() {
Expand Down
3 changes: 1 addition & 2 deletions diesel/src/query_dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,13 +1268,12 @@ pub trait QueryDsl: Sized {
/// # }
/// ```
///
/// Diesel queries also have a similar problem to [`Iterator`][iterator], where
/// Diesel queries also have a similar problem to [`Iterator`], where
/// returning them from a function requires exposing the implementation of that
/// function. The [`helper_types`][helper_types] module exists to help with this,
/// but you might want to hide the return type or have it conditionally change.
/// Boxing can achieve both.
///
/// [iterator]: std::iter::Iterator
/// [helper_types]: crate::helper_types
///
/// ### Example
Expand Down
5 changes: 2 additions & 3 deletions diesel/src/sql_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,13 @@ pub type Decimal = Numeric;
///
/// ### [`ToSql`](crate::serialize::ToSql) impls
///
/// - [`String`][String]
/// - [`String`]
/// - [`&str`][str]
///
/// ### [`FromSql`](crate::deserialize::FromSql) impls
///
/// - [`String`][String]
/// - [`String`]
///
/// [String]: std::string::String
/// [str]: https://doc.rust-lang.org/nightly/std/primitive.str.html
#[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
#[diesel(postgres_type(oid = 25, array_oid = 1009))]
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sql_types/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ impl SqlOrd for sql_types::Time {}
impl SqlOrd for sql_types::Timestamp {}
impl<T> SqlOrd for sql_types::Nullable<T> where T: SqlOrd + SqlType<IsNull = is_nullable::NotNull> {}

#[cfg(feature = "postgres")]
#[cfg(feature = "postgres_backend")]
impl SqlOrd for sql_types::Timestamptz {}
#[cfg(feature = "postgres")]
#[cfg(feature = "postgres_backend")]
impl<T: SqlOrd> SqlOrd for sql_types::Array<T> {}

#[cfg(feature = "mysql_backend")]
Expand Down
5 changes: 3 additions & 2 deletions diesel/src/sqlite/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn parse_julian(julian_days: f64) -> Option<NaiveDateTime> {
let timestamp = (julian_days - EPOCH_IN_JULIAN_DAYS) * SECONDS_IN_DAY;
let seconds = timestamp as i64;
let nanos = (timestamp.fract() * 1E9) as u32;
#[allow(deprecated)] // otherwise we would need to bump our minimal chrono version
NaiveDateTime::from_timestamp_opt(seconds, nanos)
}

Expand Down Expand Up @@ -325,11 +326,11 @@ mod tests {
#[test]
fn times_relative_to_now_encode_correctly() {
let connection = &mut connection();
let time = Utc::now().naive_utc() + Duration::seconds(60);
let time = Utc::now().naive_utc() + Duration::try_seconds(60).unwrap();
let query = select(now.lt(time));
assert_eq!(Ok(true), query.get_result(connection));

let time = Utc::now().naive_utc() - Duration::seconds(600);
let time = Utc::now().naive_utc() - Duration::try_seconds(600).unwrap();
let query = select(now.gt(time));
assert_eq!(Ok(true), query.get_result(connection));
}
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ heck = "0.4.0"
serde = { version = "1.0.0", features = ["derive"] }
toml = "0.7"
url = { version = "2.2.2" }
libsqlite3-sys = { version = ">=0.17.2, <0.28.0", optional = true }
libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true }
diffy = "0.3.0"
regex = "1.0.6"
serde_regex = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/src/infer_schema_internals/foreign_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn remove_unsafe_foreign_keys_for_codegen(
"Error loading primary keys for `{}`",
fk.parent_table
));
pk_columns.len() == 1 && Some(&pk_columns[0]) == fk.primary_key_columns.get(0)
pk_columns.len() == 1 && Some(&pk_columns[0]) == fk.primary_key_columns.first()
})
.filter(|fk| !duplicates.contains(&fk.ordered_tables()))
.cloned()
Expand Down
4 changes: 2 additions & 2 deletions diesel_compile_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c96c870

Please sign in to comment.