1use dsl_catalog::{Column, Table, display_type};
8
9pub fn table(t: &Table) -> String {
10 let mut s = format!("**table** `{}.{}`\n\n", t.schema, t.name);
11 if t.columns.is_empty() {
12 s.push_str("_no columns cached -- run :DBRefresh after switching connections_\n");
13 return s;
14 }
15 s.push_str("| column | type |\n");
16 s.push_str("|--------|------|\n");
17 for c in &t.columns {
18 s.push_str(&format!("| `{}` | `{}` |\n", c.name, display_type(&c.data_type)));
19 }
20 s
21}
22
23pub fn column(t: &Table, c: &Column) -> String {
24 format!(
27 "**column** `{}.{}.{}`\n\n\
28 - **type:** `{}`\n\
29 - **nullable:** `{}`\n",
30 t.schema,
31 t.name,
32 c.name,
33 display_type(&c.data_type),
34 c.nullable
35 )
36}