pg_helper/
table.rs

1use crate::PgType;
2use std::collections::BTreeMap;
3
4#[derive(Debug, Default, Clone)]
5pub struct PgTableDesc {
6    pub data: BTreeMap<String, Vec<PgTableItem>>,
7}
8
9impl PgTableDesc {
10    pub fn get_data(&self, key: String, case_sensitive: bool) -> Option<&Vec<PgTableItem>> {
11        let key = if case_sensitive {
12            key
13        } else {
14            key.to_uppercase()
15        };
16        self.data.get(&key)
17    }
18}
19
20#[derive(Debug, Clone)]
21pub struct PgTableItem {
22    // column name
23    pub name: String,
24    // pg table id
25    pub table_id: usize,
26    // column index
27    pub col_index: usize,
28    // pg data type
29    pub r#type: PgType,
30    // column date type length
31    pub length: usize,
32    // column date type scale
33    pub scale: usize,
34    pub nullable: bool,
35    pub default_val: Option<String>,
36    pub table_name: String,
37    pub create_time: String,
38}