-
-
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.
Rewrite
#[derive(QueryableByName)]
in derives2
Since `QueryableByName` is one of the more recently written derives, it should have been a really straightforward port. Unfortunately, the tests for this derive hit multiple rustc bugs - rust-lang/rust#47983 - rust-lang/rust#47311 I love what we were able to do with the error message here. We could even go so far as to have the `help` lines point at the struct itself for the `table_name` annotation if we want to. I also much prefer the workaround for rust-lang/rust#47311 in this PR to the one I did in #1529. I'll need to update that PR if this is merged first.
- Loading branch information
Showing
17 changed files
with
258 additions
and
128 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
..._tests/tests/compile-fail/queryable_by_name_requires_table_name_or_sql_type_annotation.rs
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...el_compile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.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,12 @@ | ||
#[macro_use] extern crate diesel; | ||
|
||
#[derive(QueryableByName)] | ||
struct Foo { | ||
foo: i32, | ||
bar: String, | ||
} | ||
|
||
#[derive(QueryableByName)] | ||
struct Bar(i32, String); | ||
|
||
fn main() {} |
46 changes: 46 additions & 0 deletions
46
...ompile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.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,46 @@ | ||
error: Cannot determine the SQL type of foo | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:5:5 | ||
| | ||
5 | foo: i32, | ||
| ^^^ | ||
| | ||
= help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` | ||
|
||
error: Cannot determine the SQL type of bar | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:6:5 | ||
| | ||
6 | bar: String, | ||
| ^^^ | ||
| | ||
= help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` | ||
|
||
error: All fields of tuple structs must be annotated with `#[column_name]` | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:10:12 | ||
| | ||
10 | struct Bar(i32, String); | ||
| ^^^ | ||
|
||
error: Cannot determine the SQL type of field | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:10:12 | ||
| | ||
10 | struct Bar(i32, String); | ||
| ^^^ | ||
| | ||
= help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` | ||
|
||
error: All fields of tuple structs must be annotated with `#[column_name]` | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:10:17 | ||
| | ||
10 | struct Bar(i32, String); | ||
| ^^^^^^ | ||
|
||
error: Cannot determine the SQL type of field | ||
--> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:10:17 | ||
| | ||
10 | struct Bar(i32, String); | ||
| ^^^^^^ | ||
| | ||
= help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` | ||
|
||
error: aborting due to 6 previous errors | ||
|
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 was deleted.
Oops, something went wrong.
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
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.