-
-
Notifications
You must be signed in to change notification settings - Fork 454
/
type_tests.rs
68 lines (55 loc) 路 1.96 KB
/
type_tests.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#![allow(unused_imports, dead_code)]
pub mod common;
use sea_orm::{IntoActiveValue, TryFromU64, TryGetable, Value};
/*
When supporting a new type in SeaORM we should implement the following traits for it:
- `IntoActiveValue`, given that it implemented `Into<Value>` already
- `TryGetable`
- `TryFromU64`
Also, we need to update `impl FromQueryResult for JsonValue` at `src/query/json.rs`
to correctly serialize the type as `serde_json::Value`.
*/
pub fn it_impl_into_active_value<T: IntoActiveValue<V>, V: Into<Value>>() {}
pub fn it_impl_try_getable<T: TryGetable>() {}
pub fn it_impl_try_from_u64<T: TryFromU64>() {}
#[allow(unused_macros)]
macro_rules! it_impl_traits {
( $ty: ty ) => {
it_impl_into_active_value::<$ty, $ty>();
it_impl_into_active_value::<Option<$ty>, Option<$ty>>();
it_impl_into_active_value::<Option<Option<$ty>>, Option<$ty>>();
it_impl_try_getable::<$ty>();
it_impl_try_getable::<Option<$ty>>();
it_impl_try_from_u64::<$ty>();
};
}
#[sea_orm_macros::test]
#[cfg(feature = "sqlx-dep")]
fn main() {
it_impl_traits!(i8);
it_impl_traits!(i16);
it_impl_traits!(i32);
it_impl_traits!(i64);
it_impl_traits!(u8);
it_impl_traits!(u16);
it_impl_traits!(u32);
it_impl_traits!(u64);
it_impl_traits!(bool);
it_impl_traits!(f32);
it_impl_traits!(f64);
it_impl_traits!(Vec<u8>);
it_impl_traits!(String);
it_impl_traits!(serde_json::Value);
it_impl_traits!(chrono::NaiveDate);
it_impl_traits!(chrono::NaiveTime);
it_impl_traits!(chrono::NaiveDateTime);
it_impl_traits!(chrono::DateTime<chrono::FixedOffset>);
it_impl_traits!(chrono::DateTime<chrono::Utc>);
it_impl_traits!(chrono::DateTime<chrono::Local>);
it_impl_traits!(time::Date);
it_impl_traits!(time::Time);
it_impl_traits!(time::PrimitiveDateTime);
it_impl_traits!(time::OffsetDateTime);
it_impl_traits!(rust_decimal::Decimal);
it_impl_traits!(uuid::Uuid);
}