-
-
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 #3359 from weiznich/try_error_messages
Add some additional checks to `#[derive(Selectable)]` to ensure field
- Loading branch information
Showing
14 changed files
with
249 additions
and
19 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
6 changes: 3 additions & 3 deletions
6
diesel_compile_tests/tests/fail/derive/unknown_attribute.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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
error: unknown attribute, expected one of `aggregate`, `not_sized`, `foreign_derive`, `table_name`, `sql_type`, `treat_none_as_default_value`, `treat_none_as_null`, `belongs_to`, `mysql_type`, `sqlite_type`, `postgres_type`, `primary_key` | ||
--> $DIR/unknown_attribute.rs:5:10 | ||
error: unknown attribute, expected one of `aggregate`, `not_sized`, `foreign_derive`, `table_name`, `sql_type`, `treat_none_as_default_value`, `treat_none_as_null`, `belongs_to`, `mysql_type`, `sqlite_type`, `postgres_type`, `primary_key`, `check_for_backend` | ||
--> tests/fail/derive/unknown_attribute.rs:5:10 | ||
| | ||
5 | #[diesel(what = true)] | ||
| ^^^^ | ||
|
||
error: unknown attribute, expected one of `embed`, `column_name`, `sql_type`, `serialize_as`, `deserialize_as`, `select_expression`, `select_expression_type` | ||
--> $DIR/unknown_attribute.rs:12:14 | ||
--> tests/fail/derive/unknown_attribute.rs:12:14 | ||
| | ||
12 | #[diesel(what = true)] | ||
| ^^^^ |
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
3 changes: 2 additions & 1 deletion
3
diesel_compile_tests/tests/fail/select_sql_still_ensures_result_type.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
39 changes: 39 additions & 0 deletions
39
diesel_compile_tests/tests/fail/selectable_with_typemisamatch.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,39 @@ | ||
extern crate diesel; | ||
|
||
use diesel::prelude::*; | ||
|
||
table! { | ||
users { | ||
id -> Integer, | ||
name -> Text, | ||
} | ||
} | ||
|
||
#[derive(Selectable, Queryable)] | ||
#[diesel(table_name = users)] | ||
#[diesel(check_for_backend(diesel::pg::Pg))] | ||
struct User { | ||
id: String, | ||
name: i32, | ||
} | ||
|
||
#[derive(Selectable, Queryable)] | ||
#[diesel(table_name = users)] | ||
#[diesel(check_for_backend(diesel::pg::Pg))] | ||
struct UserCorrect { | ||
id: i32, | ||
name: String, | ||
} | ||
|
||
fn main() { | ||
let mut conn = PgConnection::establish("...").unwrap(); | ||
|
||
users::table | ||
.select(User::as_select()) | ||
.load(&mut conn) | ||
.unwrap(); | ||
users::table | ||
.select(UserCorrect::as_select()) | ||
.load(&mut conn) | ||
.unwrap(); | ||
} |
32 changes: 32 additions & 0 deletions
32
diesel_compile_tests/tests/fail/selectable_with_typemisamatch.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,32 @@ | ||
error[E0277]: Cannot deserialize a value of the type `diesel::sql_types::Text` as `i32` | ||
--> tests/fail/selectable_with_typemisamatch.rs:17:11 | ||
| | ||
17 | name: i32, | ||
| ^^^ the trait `FromSql<diesel::sql_types::Text, Pg>` is not implemented for `i32` | ||
| | ||
= note: Double check your type mappings via the documentation of `diesel::sql_types::Text` | ||
= help: the following other types implement trait `FromSql<A, DB>`: | ||
<i32 as FromSql<diesel::sql_types::Integer, Mysql>> | ||
<i32 as FromSql<diesel::sql_types::Integer, Pg>> | ||
<i32 as FromSql<diesel::sql_types::Integer, Sqlite>> | ||
= note: required for `i32` to implement `diesel::Queryable<diesel::sql_types::Text, Pg>` | ||
= note: required for `i32` to implement `FromSqlRow<diesel::sql_types::Text, Pg>` | ||
= help: see issue #48214 | ||
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | ||
|
||
error[E0277]: Cannot deserialize a value of the type `diesel::sql_types::Integer` as `*const str` | ||
--> tests/fail/selectable_with_typemisamatch.rs:16:9 | ||
| | ||
16 | id: String, | ||
| ^^^^^^ the trait `FromSql<diesel::sql_types::Integer, Pg>` is not implemented for `*const str` | ||
| | ||
= note: Double check your type mappings via the documentation of `diesel::sql_types::Integer` | ||
= help: the following other types implement trait `FromSql<A, DB>`: | ||
<*const str as FromSql<diesel::sql_types::Text, Mysql>> | ||
<*const str as FromSql<diesel::sql_types::Text, Pg>> | ||
<*const str as FromSql<diesel::sql_types::Text, Sqlite>> | ||
= note: required for `std::string::String` to implement `FromSql<diesel::sql_types::Integer, Pg>` | ||
= note: required for `std::string::String` to implement `diesel::Queryable<diesel::sql_types::Integer, Pg>` | ||
= note: required for `std::string::String` to implement `FromSqlRow<diesel::sql_types::Integer, Pg>` | ||
= help: see issue #48214 | ||
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable |
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
Oops, something went wrong.