Skip to content

Commit

Permalink
feat(cozo-core): Add 'default_expr' column to output of '::columns'
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Apr 27, 2024
1 parent 51581fb commit 9ba19cd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cozo-core/src/runtime/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,22 +1777,28 @@ impl<'s, S: Storage<'s>> Db<S> {
let mut rows = vec![];
let mut idx = 0;
for col in &handle.metadata.keys {
let default_expr = col.default_gen.as_ref().map(|gen| format!("{}", gen));

rows.push(vec![
json!(col.name),
json!(true),
json!(idx),
json!(col.typing.to_string()),
json!(col.default_gen.is_some()),
json!(default_expr),
]);
idx += 1;
}
for col in &handle.metadata.non_keys {
let default_expr = col.default_gen.as_ref().map(|gen| format!("{}", gen));

rows.push(vec![
json!(col.name),
json!(false),
json!(idx),
json!(col.typing.to_string()),
json!(col.default_gen.is_some()),
json!(default_expr),
]);
idx += 1;
}
Expand All @@ -1807,6 +1813,7 @@ impl<'s, S: Storage<'s>> Db<S> {
"index".to_string(),
"type".to_string(),
"has_default".to_string(),
"default_expr".to_string(),
],
rows,
))
Expand Down

0 comments on commit 9ba19cd

Please sign in to comment.