forked from launchbadge/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtype_checking.rs
More file actions
56 lines (49 loc) · 1.82 KB
/
type_checking.rs
File metadata and controls
56 lines (49 loc) · 1.82 KB
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
use crate::Sqlite;
#[allow(unused_imports)]
use sqlx_core as sqlx;
// f32 is not included below as REAL represents a floating point value
// stored as an 8-byte IEEE floating point number (i.e. an f64)
// For more info see: https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
impl_type_checking!(
Sqlite {
// Note that since the macro checks `column_type_info == <T>::type_info()` first,
// we can list `bool` without it being automatically picked for all integer types
// due to its `TypeInfo::compatible()` impl.
bool,
// Since it returns `DataType::Int4` for `type_info()`,
// `i32` should only be chosen IFF the column decltype is `INT4`
i32,
i64,
f64,
String,
Vec<u8>,
#[cfg(feature = "uuid")]
sqlx::types::Uuid,
},
ParamChecking::Weak,
// While there are type integrations that must be enabled via Cargo feature,
// SQLite's type system doesn't actually have any type that we cannot decode by default.
//
// The type integrations simply allow the user to skip some intermediate representation,
// which is usually TEXT.
feature-types: _info => None,
// The expansion of the macro automatically applies the correct feature name
// and checks `[macros.preferred-crates]`
datetime-types: {
chrono: {
sqlx::types::chrono::NaiveDate,
sqlx::types::chrono::NaiveDateTime,
sqlx::types::chrono::DateTime<sqlx::types::chrono::Utc>
| sqlx::types::chrono::DateTime<_>,
},
time: {
sqlx::types::time::OffsetDateTime,
sqlx::types::time::PrimitiveDateTime,
sqlx::types::time::Date,
},
},
numeric-types: {
bigdecimal: { },
rust_decimal: { },
},
);