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
use crate::PgType;
use std::collections::BTreeMap;

#[derive(Debug, Default, Clone)]
pub struct PgTableDesc {
    pub data: BTreeMap<String, Vec<PgTableItem>>,
}

#[derive(Debug, Clone)]
pub struct PgTableItem {
    // column name
    pub name: String,
    // pg table id
    pub table_id: usize,
    // column index
    pub col_index: usize,
    // pg data type
    pub r#type: PgType,
    // column date type length
    pub length: usize,
    // column date type scale
    pub scale: usize,
    pub nullable: bool,
    pub default_val: Option<String>,
    pub table_name: String,
    pub create_time: String,
}

impl Default for PgTableItem {
    fn default() -> Self {
        PgTableItem {
            name: "".to_string(),
            table_id: 0,
            col_index: 0,
            r#type: PgType::UNKNOWN,
            length: 0,
            scale: 0,
            nullable: false,
            default_val: None,
            table_name: "".to_string(),
            create_time: "".to_string(),
        }
    }
}