use dsl_catalog::{Column, Table, display_type};
pub fn table(t: &Table) -> String {
let mut s = format!("**table** `{}.{}`\n\n", t.schema, t.name);
if t.columns.is_empty() {
s.push_str("_no columns cached -- run :DBRefresh after switching connections_\n");
return s;
}
s.push_str("| column | type |\n");
s.push_str("|--------|------|\n");
for c in &t.columns {
s.push_str(&format!("| `{}` | `{}` |\n", c.name, display_type(&c.data_type)));
}
s
}
pub fn column(t: &Table, c: &Column) -> String {
format!(
"**column** `{}.{}.{}`\n\n\
- **type:** `{}`\n\
- **nullable:** `{}`\n",
t.schema,
t.name,
c.name,
display_type(&c.data_type),
c.nullable
)
}