-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4345 from E-anae/master
Fix and/or function argument to compile check bool expression
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
diesel_compile_tests/tests/fail/and_or_functions_must_take_boolean_expr_as_attributes.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extern crate diesel; | ||
|
||
use diesel::prelude::*; | ||
|
||
table! { | ||
users { | ||
id -> Integer, | ||
name -> VarChar, | ||
} | ||
} | ||
|
||
fn main() { | ||
let conn = &mut PgConnection::establish("…").unwrap(); | ||
users::table | ||
.filter(users::id.eq(1).and(users::id).or(users::id)) | ||
.select(users::id) | ||
.execute(conn) | ||
.unwrap(); | ||
} |
37 changes: 37 additions & 0 deletions
37
diesel_compile_tests/tests/fail/and_or_functions_must_take_boolean_expr_as_attributes.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
error[E0277]: `diesel::sql_types::Integer` is neither `diesel::sql_types::Bool` nor `diesel::sql_types::Nullable<Bool>` | ||
--> tests/fail/and_or_functions_must_take_boolean_expr_as_attributes.rs:15:33 | ||
| | ||
15 | .filter(users::id.eq(1).and(users::id).or(users::id)) | ||
| ^^^ the trait `BoolOrNullableBool` is not implemented for `diesel::sql_types::Integer` | ||
| | ||
= note: try to provide an expression that produces one of the expected sql types | ||
= help: the following other types implement trait `BoolOrNullableBool`: | ||
Bool | ||
Nullable<Bool> | ||
note: required by a bound in `diesel::BoolExpressionMethods::and` | ||
--> $DIESEL/src/expression_methods/bool_expression_methods.rs | ||
| | ||
| fn and<T, ST>(self, other: T) -> dsl::And<Self, T, ST> | ||
| --- required by a bound in this associated function | ||
... | ||
| ST: SqlType + TypedExpressionType + BoolOrNullableBool, | ||
| ^^^^^^^^^^^^^^^^^^ required by this bound in `BoolExpressionMethods::and` | ||
|
||
error[E0277]: `diesel::sql_types::Integer` is neither `diesel::sql_types::Bool` nor `diesel::sql_types::Nullable<Bool>` | ||
--> tests/fail/and_or_functions_must_take_boolean_expr_as_attributes.rs:15:48 | ||
| | ||
15 | .filter(users::id.eq(1).and(users::id).or(users::id)) | ||
| ^^ the trait `BoolOrNullableBool` is not implemented for `diesel::sql_types::Integer` | ||
| | ||
= note: try to provide an expression that produces one of the expected sql types | ||
= help: the following other types implement trait `BoolOrNullableBool`: | ||
Bool | ||
Nullable<Bool> | ||
note: required by a bound in `diesel::BoolExpressionMethods::or` | ||
--> $DIESEL/src/expression_methods/bool_expression_methods.rs | ||
| | ||
| fn or<T, ST>(self, other: T) -> dsl::Or<Self, T, ST> | ||
| -- required by a bound in this associated function | ||
... | ||
| ST: SqlType + TypedExpressionType + BoolOrNullableBool, | ||
| ^^^^^^^^^^^^^^^^^^ required by this bound in `BoolExpressionMethods::or` |