From 9ba19cd4247e8ce3602028e6d986414094fa8ea6 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Sat, 27 Apr 2024 19:08:20 +0530 Subject: [PATCH] feat(cozo-core): Add 'default_expr' column to output of '::columns' Signed-off-by: Diwank Singh Tomer --- cozo-core/src/runtime/db.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cozo-core/src/runtime/db.rs b/cozo-core/src/runtime/db.rs index a89248b6..abac709b 100644 --- a/cozo-core/src/runtime/db.rs +++ b/cozo-core/src/runtime/db.rs @@ -1777,22 +1777,28 @@ impl<'s, S: Storage<'s>> Db { 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; } @@ -1807,6 +1813,7 @@ impl<'s, S: Storage<'s>> Db { "index".to_string(), "type".to_string(), "has_default".to_string(), + "default_expr".to_string(), ], rows, ))