Skip to content

Commit

Permalink
Merge pull request diesel-rs#4008 from weiznich/bump/1.78
Browse files Browse the repository at this point in the history
Bump toolchain version to 1.78
  • Loading branch information
weiznich authored May 3, 2024
2 parents 1eb97f9 + 4d775e4 commit df89687
Show file tree
Hide file tree
Showing 137 changed files with 2,502 additions and 1,599 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-15
toolchain: stable
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
Expand All @@ -337,7 +337,7 @@ jobs:
- name: Run compile tests
shell: bash
run: cargo +nightly-2024-01-15 test --manifest-path diesel_compile_tests/Cargo.toml
run: cargo +stable test --manifest-path diesel_compile_tests/Cargo.toml

rustfmt_and_clippy:
name: Check rustfmt style && run clippy
Expand Down Expand Up @@ -486,11 +486,11 @@ jobs:
run: cargo +nightly -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

minimal_rust_version:
name: Check Minimal supported rust version (1.75.0)
name: Check Minimal supported rust version (1.78.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.75.0
- uses: dtolnay/rust-toolchain@1.78.0
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
Expand All @@ -503,15 +503,15 @@ jobs:
sudo apt-get update
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
- name: Check diesel_derives
run: cargo +1.75.0 minimal-versions check -p diesel_derives --features "postgres sqlite mysql 32-column-tables 64-column-tables 128-column-tables without-deprecated with-deprecated r2d2"
run: cargo +1.78.0 minimal-versions check -p diesel_derives --features "postgres sqlite mysql 32-column-tables 64-column-tables 128-column-tables without-deprecated with-deprecated r2d2"
- name: Check diesel
run: cargo +1.75.0 minimal-versions check -p diesel --features "postgres mysql sqlite extras"
run: cargo +1.78.0 minimal-versions check -p diesel --features "postgres mysql sqlite extras"
- name: Check diesel_dynamic_schema
run: cargo +1.75.0 minimal-versions check -p diesel-dynamic-schema --all-features
run: cargo +1.78.0 minimal-versions check -p diesel-dynamic-schema --all-features
- name: Check diesel_migrations
run: cargo +1.75.0 minimal-versions check -p diesel_migrations --all-features
run: cargo +1.78.0 minimal-versions check -p diesel_migrations --all-features
- name: Check diesel_cli
run: cargo +1.75.0 minimal-versions check -p diesel_cli --features "default sqlite-bundled"
run: cargo +1.78.0 minimal-versions check -p diesel_cli --features "default sqlite-bundled"

typos:
name: Spell Check with Typos
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi

### Changed

* The minimal officially supported rustc version is now 1.75.0
* 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]`

## [2.1.0] 2023-05-26
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ members = [
]

[workspace.package]
rust-version = "1.75.0"
rust-version = "1.78.0"

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand Down
1 change: 0 additions & 1 deletion diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ postgres_backend = ["diesel_derives/postgres", "bitflags", "byteorder", "itoa"]
mysql_backend = ["diesel_derives/mysql", "byteorder"]
returning_clauses_for_sqlite_3_35 = []
i-implement-a-third-party-backend-and-opt-into-breaking-changes = []
nightly-error-messages = []
r2d2 = ["diesel_derives/r2d2", "dep:r2d2"]
chrono = ["diesel_derives/chrono", "dep:chrono"]
time = ["diesel_derives/time", "dep:time"]
Expand Down
19 changes: 7 additions & 12 deletions diesel/src/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,9 @@ pub use diesel_derives::QueryableByName;
/// }
/// }
/// ```
#[cfg_attr(
feature = "nightly-error-messages",
diagnostic::on_unimplemented(
message = "Cannot deserialize a value of the database type `{A}` as `{Self}`",
note = "Double check your type mappings via the documentation of `{A}`"
)
#[diagnostic::on_unimplemented(
message = "cannot deserialize a value of the database type `{A}` as `{Self}`",
note = "double check your type mappings via the documentation of `{A}`"
)]
pub trait FromSql<A, DB: Backend>: Sized {
/// See the trait documentation.
Expand Down Expand Up @@ -451,12 +448,10 @@ pub trait FromSql<A, DB: Backend>: Sized {
/// that implement one of the following traits:
/// * [`Queryable`]
/// * [`QueryableByName`]
#[cfg_attr(
feature = "nightly-error-messages",
diagnostic::on_unimplemented(
note = "`diesel::sql_query` requires the loading target to column names for loading values.\n\
You need to provide a type that explicitly derives `diesel::deserialize::QueryableByName`",
)
#[diagnostic::on_unimplemented(
note = "double check your type mappings via the documentation of `{ST}`",
note = "`diesel::sql_query` requires the loading target to column names for loading values.\n\
You need to provide a type that explicitly derives `diesel::deserialize::QueryableByName`"
)]
pub trait FromSqlRow<ST, DB: Backend>: Sized {
/// See the trait documentation.
Expand Down
9 changes: 3 additions & 6 deletions diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,9 @@ where
/// Notably, columns will not implement this trait for the right side of a left
/// join. To select a column or expression using a column from the right side of
/// a left join, you must call `.nullable()` on it.
#[cfg_attr(
feature = "nightly-error-messages",
diagnostic::on_unimplemented(
message = "Cannot select `{Self}` from `{QS}`",
note = "`{Self}` is no valid selection for `{QS}`"
)
#[diagnostic::on_unimplemented(
message = "Cannot select `{Self}` from `{QS}`",
note = "`{Self}` is no valid selection for `{QS}`"
)]
pub trait SelectableExpression<QS: ?Sized>: AppearsOnTable<QS> {}

Expand Down
12 changes: 12 additions & 0 deletions diesel/src/expression/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,18 @@ where
}
}

#[diagnostic::on_unimplemented(
message = "Cannot use the `LIKE` operator with expressions of the type `{ST}` for the backend `{Self}`",
note = "Expressions of the type `diesel::sql_types::Text` and `diesel::sql_types::Nullable<Text>` are \n\
allowed for all backends"
)]
#[cfg_attr(
feature = "postgres_backend",
diagnostic::on_unimplemented(
note = "Expressions of the type `diesel::sql_types::Binary` and `diesel::sql_types::Nullable<Binary>` are \n\
allowed for the PostgreSQL backend"
)
)]
pub trait LikeIsAllowedForType<ST>: Backend {}

impl<DB> LikeIsAllowedForType<crate::sql_types::Text> for DB where DB: Backend {}
Expand Down
9 changes: 0 additions & 9 deletions diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
//! by rustc, including the `required because of …` part of the message.
//! Your IDE might hide important parts!
//!
//! If you use a nightly compiler you might want to enable the `nightly-error-messages`
//! feature flag to automatically improve some error messages.
//!
//! The following error messages are common:
//!
//! * `the trait bound (diesel::sql_types::Integer, …, diesel::sql_types::Text): load_dsl::private::CompatibleType<YourModel, Pg> is not satisfied`
Expand Down Expand Up @@ -212,18 +209,12 @@
//! explicitly opts out the stability guarantee given by diesel. This feature overrides the `with-deprecated`.
//! Note that this may also remove items that are not shown as `#[deprecated]` in our documentation, due to
//! various bugs in rustdoc. It can be used to check if you depend on any such hidden `#[deprecated]` item.
//! - `nightly-error-messages`: This feature enables the generation of improved compiler error messages for
//! common mistakes using diesel. This feature requires a nightly rust compiler and is considered to be unstable.
//! It requires adding `#![feature(diagnostic_namespace)]` to your crate.
//! We might remove it in future diesel versions without replacement or deprecation.
//!
//!
//! By default the following features are enabled:
//!
//! - `with-deprecated`
//! - `32-column-tables`
#![cfg_attr(feature = "nightly-error-messages", feature(diagnostic_namespace))]
#![cfg_attr(feature = "unstable", feature(trait_alias))]
#![cfg_attr(doc_cfg, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(feature = "128-column-tables", recursion_limit = "256")]
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ConnectionOptions {
}

let query_pairs = url.query_pairs().into_owned().collect::<HashMap<_, _>>();
if query_pairs.get("database").is_some() {
if query_pairs.contains_key("database") {
return Err(connection_url_error());
}

Expand Down
36 changes: 36 additions & 0 deletions diesel/src/pg/expression/expression_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2406,12 +2406,20 @@ pub(in crate::pg) mod private {
/// Marker trait used to implement `ArrayExpressionMethods` on the appropriate
/// types. Once coherence takes associated types into account, we can remove
/// this trait.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Array<_>` nor `diesel::sql_types::Nullable<Array<_>>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait ArrayOrNullableArray {}

impl<T> ArrayOrNullableArray for Array<T> {}
impl<T> ArrayOrNullableArray for Nullable<Array<T>> {}

/// Marker trait used to implement `PgNetExpressionMethods` on the appropriate types.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Inet`, `diesel::sql_types::Cidr`, `diesel::sql_types::Nullable<Inet>` nor `diesel::sql_types::Nullable<Cidr>",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait InetOrCidr {}

impl InetOrCidr for Inet {}
Expand All @@ -2422,6 +2430,10 @@ pub(in crate::pg) mod private {
/// Marker trait used to implement `PgTextExpressionMethods` on the appropriate
/// types. Once coherence takes associated types into account, we can remove
/// this trait.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Text` nor `diesel::sql_types::Nullable<Text>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait TextOrNullableText {}

impl TextOrNullableText for Text {}
Expand All @@ -2443,12 +2455,20 @@ pub(in crate::pg) mod private {
/// Marker trait used to implement `PgRangeExpressionMethods` on the appropriate
/// types. Once coherence takes associated types into account, we can remove
/// this trait.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Range<_>` nor `diesel::sql_types::Nullable<Range<_>>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait RangeOrNullableRange {}

impl<ST> RangeOrNullableRange for Range<ST> {}
impl<ST> RangeOrNullableRange for Nullable<Range<ST>> {}

/// Marker trait used to implement `PgJsonbExpressionMethods` on the appropriate types.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Jsonb` nor `diesel::sql_types::Nullable<Jsonb>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait JsonbOrNullableJsonb {}

impl JsonbOrNullableJsonb for Jsonb {}
Expand Down Expand Up @@ -2523,13 +2543,21 @@ pub(in crate::pg) mod private {
}
}

#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Text`, `diesel::sql_types::Integer` nor `diesel::sql_types::Array<Text>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait TextArrayOrTextOrInteger {}

impl TextArrayOrTextOrInteger for Array<Text> {}
impl TextArrayOrTextOrInteger for Text {}
impl TextArrayOrTextOrInteger for Integer {}

/// Marker trait used to implement `PgAnyJsonExpressionMethods` on the appropriate types.
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Json`, `diesel::sql_types::Jsonb`, `diesel::sql_types::Nullable<Json>` nor `diesel::sql_types::Nullable<Jsonb>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait JsonOrNullableJsonOrJsonbOrNullableJsonb {}
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Json {}
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Nullable<Json> {}
Expand Down Expand Up @@ -2578,10 +2606,18 @@ pub(in crate::pg) mod private {
}
}

#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Text` nor `diesel::sql_types::Integer`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait TextOrInteger {}
impl TextOrInteger for Text {}
impl TextOrInteger for Integer {}

#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Binary` nor `diesel::sql_types::Nullable<Binary>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait BinaryOrNullableBinary {}

impl BinaryOrNullableBinary for Binary {}
Expand Down
5 changes: 5 additions & 0 deletions diesel/src/query_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ pub trait SelectQuery {
///
/// [`ExecuteDsl`]: crate::query_dsl::methods::ExecuteDsl
/// [`LoadQuery`]: crate::query_dsl::methods::LoadQuery
#[diagnostic::on_unimplemented(
message = "`{Self}` is no valid SQL fragment for the `{DB}` backend",
note = "this usually means that the `{DB}` database system does not support \n\
this SQL syntax"
)]
pub trait QueryFragment<DB: Backend, SP = self::private::NotSpecialized> {
/// Walk over this `QueryFragment` for all passes.
///
Expand Down
12 changes: 5 additions & 7 deletions diesel/src/query_dsl/load_dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,11 @@ mod private {
doc_cfg,
doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
)]
#[cfg_attr(
feature = "nightly-error-messages",
diagnostic::on_unimplemented(
note = "This is a mismatch between what your query returns and what your type expects the query to return\n\
Consider using `#[derive(Selectable)]` + `#[diesel(check_for_backend({DB}))]` on your struct `{U}` and \n\
in your query `.select({U}::as_select())` to get a better error message",
)
#[diagnostic::on_unimplemented(
note = "this is a mismatch between what your query returns and what your type expects the query to return",
note = "the fields in your struct need to match the fields returned by your query in count, order and type",
note = "consider using `#[derive(Selectable)]` + `#[diesel(check_for_backend({DB}))]` on your struct `{U}` and \n\
in your query `.select({U}::as_select())` to get a better error message"
)]
pub trait CompatibleType<U, DB> {
type SqlType;
Expand Down
4 changes: 4 additions & 0 deletions diesel/src/query_source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ pub trait AppearsInFromClause<QS> {
/// (no call to [`allow_tables_to_appear_in_same_query!`] was made)
/// - You are attempting to use two aliases to the same table in the same query, but they
/// were declared through different calls to [`alias!`](crate::alias)
#[diagnostic::on_unimplemented(
note = "double check that `{T}` and `{Self}` appear in the same `allow_tables_to_appear_in_same_query!` \ncall if both are tables",
note = "double check that `{T}` and `{Self}` appear in the same `alias!` call if both \nare aliases to the same table"
)]
pub trait TableNotEqual<T: Table>: Table {}

impl<T1, T2> AppearsInFromClause<T2> for T1
Expand Down
4 changes: 4 additions & 0 deletions diesel/src/sql_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ pub mod is_nullable {

/// A marker trait for accepting expressions of the type `Bool` and
/// `Nullable<Bool>` in the same place
#[diagnostic::on_unimplemented(
message = "`{Self}` is neither `diesel::sql_types::Bool` nor `diesel::sql_types::Nullable<Bool>`",
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait BoolOrNullableBool {}

impl BoolOrNullableBool for Bool {}
Expand Down
3 changes: 3 additions & 0 deletions diesel/src/sql_types/ord.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::sql_types::{self, is_nullable, SqlType};

/// Marker trait for types which can be used with `MAX` and `MIN`
#[diagnostic::on_unimplemented(
message = "expressions of the type `{Self}` cannot be ordered by the database"
)]
pub trait SqlOrd: SqlType {}

impl SqlOrd for sql_types::SmallInt {}
Expand Down
Loading

0 comments on commit df89687

Please sign in to comment.