mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
fix: derive(Type) should emit a forwarded impl for the compatible function
This commit is contained in:
parent
edcc91c9f2
commit
b6e1275617
3 changed files with 23 additions and 0 deletions
|
@ -160,6 +160,11 @@ name = "sqlite-macros"
|
|||
path = "tests/sqlite/macros.rs"
|
||||
required-features = [ "sqlite", "macros" ]
|
||||
|
||||
[[test]]
|
||||
name = "sqlite-derives"
|
||||
path = "tests/sqlite/derives.rs"
|
||||
required-features = [ "sqlite", "macros" ]
|
||||
|
||||
#
|
||||
# MySQL
|
||||
#
|
||||
|
|
|
@ -118,6 +118,10 @@ fn expand_derive_has_sql_type_weak_enum(
|
|||
fn type_info() -> DB::TypeInfo {
|
||||
<#repr as ::sqlx::Type<DB>>::type_info()
|
||||
}
|
||||
|
||||
fn compatible(ty: &DB::TypeInfo) -> bool {
|
||||
<#repr as ::sqlx::Type<DB>>::compatible(ty)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
14
tests/sqlite/derives.rs
Normal file
14
tests/sqlite/derives.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use sqlx::Sqlite;
|
||||
use sqlx_test::{new, test_type};
|
||||
|
||||
#[derive(Debug, PartialEq, sqlx::Type)]
|
||||
#[repr(u32)]
|
||||
enum Origin {
|
||||
Foo = 1,
|
||||
Bar = 2,
|
||||
}
|
||||
|
||||
test_type!(origin_enum<Origin>(Sqlite,
|
||||
"1" == Origin::Foo,
|
||||
"2" == Origin::Bar,
|
||||
));
|
Loading…
Reference in a new issue