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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#[cfg(feature = "chrono")]
extern crate chrono;
#[cfg(feature = "postgres")]
extern crate postgres;
#[cfg(feature = "rusqlite")]
extern crate rusqlite;
pub mod aggregates;
mod methods;
mod types;
pub use types::{Date, DateTime, Time, ToTqlType};
use types::StdI32;
pub use types::numbers::{i16, i32, i64, i8, u16, u32, u64, u8};
pub type ForeignKey<T> = Option<T>;
pub type PrimaryKey = StdI32;
#[doc(hidden)]
pub unsafe trait SqlTable {
#[cfg(feature = "postgres")]
const FIELD_COUNT: usize;
#[cfg(feature = "rusqlite")]
const FIELD_COUNT: StdI32;
fn _tql_default() -> Self;
#[cfg(feature = "postgres")]
fn from_row(row: &::postgres::rows::Row) -> Self;
#[cfg(feature = "postgres")]
fn from_related_row(row: &::postgres::rows::Row, delta: usize) -> Self;
#[cfg(feature = "rusqlite")]
fn from_row(row: &::rusqlite::Row) -> Self;
#[cfg(feature = "rusqlite")]
fn from_related_row(row: &::rusqlite::Row, delta: StdI32) -> Self;
}
#[cfg(feature = "postgres")]
#[doc(hidden)]
pub fn from_related_row<T: SqlTable>(field: &mut Option<T>, row: &::postgres::rows::Row, delta: usize) -> usize
{
*field = Some(T::from_related_row(row, delta));
T::FIELD_COUNT
}
#[cfg(feature = "rusqlite")]
#[doc(hidden)]
pub fn from_related_row<T: SqlTable>(field: &mut Option<T>, row: &::rusqlite::Row, delta: StdI32) -> StdI32
{
*field = Some(T::from_related_row(row, delta));
T::FIELD_COUNT
}
#[cfg(not(unstable))]
#[macro_export]
macro_rules! check_missing_fields {
($($tt:tt)*) => {{
#[derive(StableCheckMissingFields)]
enum __TqlStableCheckMissingFieldEnum {
Input = (stringify!($($tt)*), 0).1,
}
__tql_call_macro_missing_fields!()
}};
}
#[cfg(not(unstable))]
#[macro_export]
macro_rules! sql {
($connection:ident, $($tt:tt)*) => {{
#[derive(StableToSql)]
enum __TqlStableToSqlEnum {
Input = (stringify!($($tt)*), 0).1,
}
__tql_call_macro!($connection, $($tt)*)
}};
}