Skip to content

Commit

Permalink
Merge pull request #262 from julep-ai/f/add-default-expr-to-columns-o…
Browse files Browse the repository at this point in the history
…utput

feat(cozo-core): Add 'default_expr' column to output of '::columns'
  • Loading branch information
zh217 authored May 9, 2024
2 parents 51581fb + 9ba19cd commit eb43679
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 eb43679

Please sign in to comment.