Skip to content

Commit

Permalink
Build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Jan 28, 2025
1 parent c0d44e8 commit 57e357a
Show file tree
Hide file tree
Showing 83 changed files with 508 additions and 403 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ concurrency:
jobs:
check_and_test:
name: Check
needs: [sqlite_bundled, rustfmt_and_clippy, postgres_bundled, mysql_bundled, typos]
needs:
[
sqlite_bundled,
rustfmt_and_clippy,
postgres_bundled,
mysql_bundled,
typos,
]
strategy:
fail-fast: false
matrix:
Expand All @@ -38,6 +45,12 @@ jobs:
with:
key: ${{ matrix.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Set environment variables
shell: bash
if: matrix.backend == 'mysql'
run: |
echo "RUST_TEST_THREADS=1" >> $GITHUB_ENV
- name: Set environment variables
shell: bash
if: matrix.rust == 'nightly'
Expand Down Expand Up @@ -128,7 +141,7 @@ jobs:
sleep 3
/opt/homebrew/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot
echo "MYSQL_DATABASE_URL=mysql://[email protected]/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root@l127.0.0.1/diesel_example" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root@127.0.0.1/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://[email protected]/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/[email protected]/lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=8.4" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions diesel/src/connection/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub enum InstrumentationEvent<'a> {
// these constructors exist to
// keep `#[non_exhaustive]` on all the variants
// and to gate the constructors on the unstable feature
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
impl<'a> InstrumentationEvent<'a> {
/// Create a new `InstrumentationEvent::StartEstablishConnection` event
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
Expand Down
12 changes: 9 additions & 3 deletions diesel/src/pg/expression/extensions/interval_dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,12 @@ mod tests {

macro_rules! test_fn {
($tpe:ty, $test_name:ident, $units: ident, $max_range: expr) => {
test_fn!($tpe, $test_name, $units, $max_range, 1);
test_fn!($tpe, $test_name, $units, $max_range, 1, 0);
};
($tpe:ty, $test_name:ident, $units:ident, $max_range: expr, $max_diff: expr) => {
test_fn!($tpe, $test_name, $units, $max_range, $max_diff, 0);
};
($tpe:ty, $test_name:ident, $units:ident, $max_range: expr, $max_diff: expr, $max_month_diff: expr) => {
fn $test_name(val: $tpe) -> bool {
if val > $max_range || val < (-1 as $tpe) * $max_range || (val as f64).is_nan() {
return true;
Expand All @@ -278,7 +281,7 @@ mod tests {
query
.get_result::<PgInterval>(conn)
.map(|res| {
value.months == res.months
(value.months - res.months).abs() <= $max_month_diff
&& value.days == res.days
&& (value.microseconds - res.microseconds).abs() <= $max_diff
})
Expand Down Expand Up @@ -342,6 +345,9 @@ mod tests {
test_fn!(f64, test_days, days, i32::MAX as f64, MAX_DIFF);
test_fn!(f64, test_weeks, weeks, (i32::MAX / 7) as f64, MAX_DIFF);
test_fn!(f64, test_months, months, i32::MAX as f64, MAX_DIFF);
test_fn!(f64, test_years, years, (i32::MAX / 12) as f64, MAX_DIFF);
// different postgres versions seem to round intervals with years differently
// -1681.9781874756495 years is reported as -20183 months for postgres 14
// and as -20184 months for postgres 16
test_fn!(f64, test_years, years, (i32::MAX / 12) as f64, MAX_DIFF, 1);
}
}
4 changes: 2 additions & 2 deletions diesel/src/pg/types/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<ST: 'static, T> AsExpression<Range<ST>> for (Bound<T>, Bound<T>) {
}

#[cfg(feature = "postgres_backend")]
impl<'a, ST: 'static, T> AsExpression<Range<ST>> for &'a (Bound<T>, Bound<T>) {
impl<ST: 'static, T> AsExpression<Range<ST>> for &(Bound<T>, Bound<T>) {
type Expression = SqlBound<Range<ST>, Self>;

fn as_expression(self) -> Self::Expression {
Expand All @@ -52,7 +52,7 @@ impl<ST: 'static, T> AsExpression<Nullable<Range<ST>>> for (Bound<T>, Bound<T>)
}

#[cfg(feature = "postgres_backend")]
impl<'a, ST: 'static, T> AsExpression<Nullable<Range<ST>>> for &'a (Bound<T>, Bound<T>) {
impl<ST: 'static, T> AsExpression<Nullable<Range<ST>>> for &(Bound<T>, Bound<T>) {
type Expression = SqlBound<Nullable<Range<ST>>, Self>;

fn as_expression(self) -> Self::Expression {
Expand Down
3 changes: 2 additions & 1 deletion diesel/src/pg/types/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ fn some_uuid_from_sql() {
];
let input_uuid = uuid::Uuid::from_slice(&bytes).unwrap();
let output_uuid =
FromSql::<Uuid, Pg>::from_sql(PgValue::for_test(input_uuid.as_bytes())).unwrap();
<uuid::Uuid as FromSql<Uuid, Pg>>::from_sql(PgValue::for_test(input_uuid.as_bytes()))
.unwrap();
assert_eq!(input_uuid, output_uuid);
}

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.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: Cannot select `posts::columns::id` from `users::table`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:21:31
|
21 | let source = users::table.select(sum(posts::id));
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`, which is required by `SelectStatement<FromClause<users::table>>: SelectDsl<_>`
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`
|
= note: `posts::columns::id` is no valid selection for `users::table`
= help: the following other types implement trait `SelectableExpression<QS>`:
Expand All @@ -20,7 +20,7 @@ error[E0271]: type mismatch resolving `<table as AppearsInFromClause<table>>::Co
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:21:31
|
21 | let source = users::table.select(sum(posts::id));
| ^^^^^^ expected `Never`, found `Once`
| ^^^^^^ expected `Once`, found `Never`
|
note: required for `posts::columns::id` to implement `AppearsOnTable<users::table>`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:13:9
Expand All @@ -37,7 +37,7 @@ error[E0277]: Cannot select `posts::columns::id` from `users::table`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:22:31
|
22 | let source = users::table.select(avg(posts::id));
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`, which is required by `SelectStatement<FromClause<users::table>>: SelectDsl<_>`
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`
|
= note: `posts::columns::id` is no valid selection for `users::table`
= help: the following other types implement trait `SelectableExpression<QS>`:
Expand All @@ -55,7 +55,7 @@ error[E0271]: type mismatch resolving `<table as AppearsInFromClause<table>>::Co
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:22:31
|
22 | let source = users::table.select(avg(posts::id));
| ^^^^^^ expected `Never`, found `Once`
| ^^^^^^ expected `Once`, found `Never`
|
note: required for `posts::columns::id` to implement `AppearsOnTable<users::table>`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:13:9
Expand All @@ -72,7 +72,7 @@ error[E0277]: Cannot select `posts::columns::id` from `users::table`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:23:31
|
23 | let source = users::table.select(max(posts::id));
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`, which is required by `SelectStatement<FromClause<users::table>>: SelectDsl<_>`
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`
|
= note: `posts::columns::id` is no valid selection for `users::table`
= help: the following other types implement trait `SelectableExpression<QS>`:
Expand All @@ -90,7 +90,7 @@ error[E0271]: type mismatch resolving `<table as AppearsInFromClause<table>>::Co
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:23:31
|
23 | let source = users::table.select(max(posts::id));
| ^^^^^^ expected `Never`, found `Once`
| ^^^^^^ expected `Once`, found `Never`
|
note: required for `posts::columns::id` to implement `AppearsOnTable<users::table>`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:13:9
Expand All @@ -107,7 +107,7 @@ error[E0277]: Cannot select `posts::columns::id` from `users::table`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:24:31
|
24 | let source = users::table.select(min(posts::id));
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`, which is required by `SelectStatement<FromClause<users::table>>: SelectDsl<_>`
| ^^^^^^ the trait `SelectableExpression<users::table>` is not implemented for `posts::columns::id`
|
= note: `posts::columns::id` is no valid selection for `users::table`
= help: the following other types implement trait `SelectableExpression<QS>`:
Expand All @@ -125,7 +125,7 @@ error[E0271]: type mismatch resolving `<table as AppearsInFromClause<table>>::Co
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:24:31
|
24 | let source = users::table.select(min(posts::id));
| ^^^^^^ expected `Never`, found `Once`
| ^^^^^^ expected `Once`, found `Never`
|
note: required for `posts::columns::id` to implement `AppearsOnTable<users::table>`
--> tests/fail/aggregate_expression_requires_column_from_same_table.rs:13:9
Expand Down
2 changes: 1 addition & 1 deletion diesel_compile_tests/tests/fail/alias_and_group_by.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<name as IsContainedInGroupBy<id>>::Outpu
34 | .select(user_alias.field(users::id))
| ^^^^^^ type mismatch resolving `<name as IsContainedInGroupBy<id>>::Output == Yes`
|
note: expected this to be `diesel::expression::is_contained_in_group_by::No`
note: expected this to be `diesel::expression::is_contained_in_group_by::Yes`
--> tests/fail/alias_and_group_by.rs:9:9
|
9 | name -> VarChar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: Cannot select `f64` from `NoFromClause`
--> tests/fail/array_expressions_must_be_correct_type.rs:9:12
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ------ ^^^^^^^^^^^^^^^^^^^ the trait `SelectableExpression<NoFromClause>` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<_>>: AsQuery`
| ------ ^^^^^^^^^^^^^^^^^^^ the trait `SelectableExpression<NoFromClause>` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -36,7 +36,7 @@ error[E0277]: the trait bound `f64: ValidGrouping<()>` is not satisfied
--> tests/fail/array_expressions_must_be_correct_type.rs:9:12
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ------ ^^^^^^^^^^^^^^^^^^^ the trait `ValidGrouping<()>` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<_>>: AsQuery`
| ------ ^^^^^^^^^^^^^^^^^^^ the trait `ValidGrouping<()>` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -68,7 +68,7 @@ error[E0277]: Cannot select `f64` from `NoFromClause`
--> tests/fail/array_expressions_must_be_correct_type.rs:9:56
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ---------- ^^^^^^^^^^^^^^^ the trait `SelectableExpression<NoFromClause>` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<diesel::pg::expression::array::ArrayLiteral<(_, _), _>>>: LoadQuery<'_, _, Vec<i32>>`
| ---------- ^^^^^^^^^^^^^^^ the trait `SelectableExpression<NoFromClause>` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -102,7 +102,7 @@ error[E0277]: the trait bound `f64: ValidGrouping<()>` is not satisfied
--> tests/fail/array_expressions_must_be_correct_type.rs:9:56
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ---------- ^^^^^^^^^^^^^^^ the trait `ValidGrouping<()>` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<diesel::pg::expression::array::ArrayLiteral<(_, _), _>>>: LoadQuery<'_, _, Vec<i32>>`
| ---------- ^^^^^^^^^^^^^^^ the trait `ValidGrouping<()>` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -134,7 +134,7 @@ error[E0277]: the trait bound `f64: QueryId` is not satisfied
--> tests/fail/array_expressions_must_be_correct_type.rs:9:56
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ---------- ^^^^^^^^^^^^^^^ the trait `QueryId` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<diesel::pg::expression::array::ArrayLiteral<(_, _), _>>>: LoadQuery<'_, _, Vec<i32>>`
| ---------- ^^^^^^^^^^^^^^^ the trait `QueryId` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -165,7 +165,7 @@ error[E0277]: `f64` is no valid SQL fragment for the `Pg` backend
--> tests/fail/array_expressions_must_be_correct_type.rs:9:56
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ---------- ^^^^^^^^^^^^^^^ the trait `QueryFragment<Pg>` is not implemented for `f64`, which is required by `SelectStatement<NoFromClause, diesel::query_builder::select_clause::SelectClause<diesel::pg::expression::array::ArrayLiteral<(_, _), _>>>: LoadQuery<'_, _, Vec<i32>>`
| ---------- ^^^^^^^^^^^^^^^ the trait `QueryFragment<Pg>` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down Expand Up @@ -198,7 +198,7 @@ error[E0277]: the trait bound `f64: diesel::Expression` is not satisfied
--> tests/fail/array_expressions_must_be_correct_type.rs:9:19
|
9 | select(array((1f64, 3f64))).get_result::<Vec<i32>>(&mut connection);
| ----- ^^^^ the trait `diesel::Expression` is not implemented for `f64`, which is required by `(f64, f64): AsExpressionList<_>`
| ----- ^^^^ the trait `diesel::Expression` is not implemented for `f64`
| |
| required by a bound introduced by this call
|
Expand Down
Loading

0 comments on commit 57e357a

Please sign in to comment.