-
-
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 #4354 from Ten0/fix_eq_any_nullability
Fix eq_any's nullability
- Loading branch information
Showing
4 changed files
with
62 additions
and
7 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
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
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,20 @@ | ||
extern crate diesel; | ||
|
||
use diesel::*; | ||
|
||
table! { | ||
users{ | ||
id -> Integer, | ||
name -> Nullable<Text>, | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut conn = PgConnection::establish("").unwrap(); | ||
// Should not be allowed because `users::name` is nullable, so the result of `eq_any` is | ||
// nullable as well. | ||
let _: Vec<bool> = users::table | ||
.select(users::name.eq_any(["foo", "bar"])) | ||
.load(&mut conn) | ||
.unwrap(); | ||
} |
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,25 @@ | ||
error[E0277]: cannot deserialize a value of the database type `diesel::sql_types::Nullable<Bool>` as `bool` | ||
--> tests/fail/eq_any_is_nullable.rs:18:15 | ||
| | ||
18 | .load(&mut conn) | ||
| ---- ^^^^^^^^^ the trait `FromSql<diesel::sql_types::Nullable<Bool>, Pg>` is not implemented for `bool`, which is required by `SelectStatement<FromClause<users::table>, diesel::query_builder::select_clause::SelectClause<diesel::expression::grouped::Grouped<In<columns::name, Many<diesel::sql_types::Nullable<diesel::sql_types::Text>, &str>>>>>: LoadQuery<'_, _, _>` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= note: double check your type mappings via the documentation of `diesel::sql_types::Nullable<Bool>` | ||
= help: the following other types implement trait `FromSql<A, DB>`: | ||
`bool` implements `FromSql<Bool, Mysql>` | ||
`bool` implements `FromSql<Bool, Pg>` | ||
`bool` implements `FromSql<Bool, Sqlite>` | ||
= note: required for `bool` to implement `Queryable<diesel::sql_types::Nullable<Bool>, Pg>` | ||
= note: required for `bool` to implement `FromSqlRow<diesel::sql_types::Nullable<Bool>, Pg>` | ||
= note: required for `diesel::sql_types::Nullable<Bool>` to implement `load_dsl::private::CompatibleType<bool, Pg>` | ||
= note: required for `SelectStatement<FromClause<users::table>, diesel::query_builder::select_clause::SelectClause<diesel::expression::grouped::Grouped<In<columns::name, Many<diesel::sql_types::Nullable<diesel::sql_types::Text>, &str>>>>>` to implement `LoadQuery<'_, diesel::PgConnection, bool>` | ||
note: required by a bound in `diesel::RunQueryDsl::load` | ||
--> $DIESEL/src/query_dsl/mod.rs | ||
| | ||
| fn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>> | ||
| ---- required by a bound in this associated function | ||
| where | ||
| Self: LoadQuery<'query, Conn, U>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::load` |