forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_structures.rs
More file actions
51 lines (45 loc) · 1.19 KB
/
Copy pathdata_structures.rs
File metadata and controls
51 lines (45 loc) · 1.19 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
use diesel::*;
#[cfg(feature = "postgres")]
use diesel::pg::Pg;
#[cfg(feature = "sqlite")]
use diesel::sqlite::Sqlite;
use diesel::types::{HasSqlType, FromSqlRow};
#[derive(Debug, Clone)]
pub struct ColumnInformation {
pub column_name: String,
pub type_name: String,
pub nullable: bool,
}
pub struct ColumnType {
pub path: Vec<String>,
pub is_array: bool,
pub is_nullable: bool,
}
#[cfg(feature = "postgres")]
impl<ST> Queryable<ST, Pg> for ColumnInformation where
Pg: HasSqlType<ST>,
(String, String, bool): FromSqlRow<ST, Pg>,
{
type Row = (String, String, bool);
fn build(row: Self::Row) -> Self {
ColumnInformation {
column_name: row.0,
type_name: row.1,
nullable: !row.2,
}
}
}
#[cfg(feature = "sqlite")]
impl<ST> Queryable<ST, Sqlite> for ColumnInformation where
Sqlite: HasSqlType<ST>,
(i32, String, String, bool, Option<String>, bool): FromSqlRow<ST, Sqlite>,
{
type Row = (i32, String, String, bool, Option<String>, bool);
fn build(row: Self::Row) -> Self {
ColumnInformation {
column_name: row.1,
type_name: row.2,
nullable: !row.3,
}
}
}