forked from sfackler/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(derive): add
#[postgres(allow_mismatch)]
- Loading branch information
1 parent
790af54
commit 258fe68
Showing
8 changed files
with
250 additions
and
27 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
postgres-derive-test/src/compile-fail/invalid-allow-mismatch.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,31 @@ | ||
use postgres_types::{FromSql, ToSql}; | ||
|
||
#[derive(ToSql, Debug)] | ||
#[postgres(allow_mismatch)] | ||
struct ToSqlAllowMismatchStruct { | ||
a: i32, | ||
} | ||
|
||
#[derive(FromSql, Debug)] | ||
#[postgres(allow_mismatch)] | ||
struct FromSqlAllowMismatchStruct { | ||
a: i32, | ||
} | ||
|
||
#[derive(ToSql, Debug)] | ||
#[postgres(allow_mismatch)] | ||
struct ToSqlAllowMismatchTupleStruct(i32, i32); | ||
|
||
#[derive(FromSql, Debug)] | ||
#[postgres(allow_mismatch)] | ||
struct FromSqlAllowMismatchTupleStruct(i32, i32); | ||
|
||
#[derive(FromSql, Debug)] | ||
#[postgres(transparent, allow_mismatch)] | ||
struct TransparentFromSqlAllowMismatchStruct(i32); | ||
|
||
#[derive(FromSql, Debug)] | ||
#[postgres(allow_mismatch, transparent)] | ||
struct AllowMismatchFromSqlTransparentStruct(i32); | ||
|
||
fn main() {} |
43 changes: 43 additions & 0 deletions
43
postgres-derive-test/src/compile-fail/invalid-allow-mismatch.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,43 @@ | ||
error: #[postgres(allow_mismatch)] may only be applied to enums | ||
--> src/compile-fail/invalid-allow-mismatch.rs:4:1 | ||
| | ||
4 | / #[postgres(allow_mismatch)] | ||
5 | | struct ToSqlAllowMismatchStruct { | ||
6 | | a: i32, | ||
7 | | } | ||
| |_^ | ||
|
||
error: #[postgres(allow_mismatch)] may only be applied to enums | ||
--> src/compile-fail/invalid-allow-mismatch.rs:10:1 | ||
| | ||
10 | / #[postgres(allow_mismatch)] | ||
11 | | struct FromSqlAllowMismatchStruct { | ||
12 | | a: i32, | ||
13 | | } | ||
| |_^ | ||
|
||
error: #[postgres(allow_mismatch)] may only be applied to enums | ||
--> src/compile-fail/invalid-allow-mismatch.rs:16:1 | ||
| | ||
16 | / #[postgres(allow_mismatch)] | ||
17 | | struct ToSqlAllowMismatchTupleStruct(i32, i32); | ||
| |_______________________________________________^ | ||
|
||
error: #[postgres(allow_mismatch)] may only be applied to enums | ||
--> src/compile-fail/invalid-allow-mismatch.rs:20:1 | ||
| | ||
20 | / #[postgres(allow_mismatch)] | ||
21 | | struct FromSqlAllowMismatchTupleStruct(i32, i32); | ||
| |_________________________________________________^ | ||
|
||
error: #[postgres(transparent)] is not allowed with #[postgres(allow_mismatch)] | ||
--> src/compile-fail/invalid-allow-mismatch.rs:24:25 | ||
| | ||
24 | #[postgres(transparent, allow_mismatch)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: #[postgres(allow_mismatch)] is not allowed with #[postgres(transparent)] | ||
--> src/compile-fail/invalid-allow-mismatch.rs:28:28 | ||
| | ||
28 | #[postgres(allow_mismatch, transparent)] | ||
| ^^^^^^^^^^^ |
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
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