add derives for Encode and Decode

This commit is contained in:
Tom Dohrmann
2020-01-18 13:30:16 +01:00
parent 9141bd7561
commit bb933decb7
6 changed files with 170 additions and 1 deletions

27
tests/derives.rs Normal file
View File

@@ -0,0 +1,27 @@
#[test]
#[cfg(feature = "macros")]
fn encode() {
use sqlx::encode::Encode;
#[derive(Encode)]
struct Foo(i32);
#[cfg(feature = "postgres")]
let _: Box<dyn Encode<sqlx::Postgres>> = Box::new(Foo(1));
#[cfg(feature = "mysql")]
let _: Box<dyn Encode<sqlx::MySql>> = Box::new(Foo(1));
}
#[test]
#[cfg(feature = "macros")]
fn decode() {
use sqlx::decode::Decode;
#[derive(Decode)]
struct Foo(i32);
#[cfg(feature = "postgres")]
let _: Box<dyn Decode<sqlx::Postgres>> = Box::new(Foo(1));
#[cfg(feature = "mysql")]
let _: Box<dyn Decode<sqlx::MySql>> = Box::new(Foo(1));
}