fix: derive(Type) should emit a forwarded impl for the compatible function

This commit is contained in:
Ryan Leckey 2021-03-18 16:12:00 -07:00
parent edcc91c9f2
commit b6e1275617
No known key found for this signature in database
GPG key ID: F8AA68C235AB08C9
3 changed files with 23 additions and 0 deletions

View file

@ -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
#

View file

@ -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
View 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,
));