From ba5c1436ffae0af53f1f1269246ab3a980355e5b Mon Sep 17 00:00:00 2001 From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:12:23 +0900 Subject: [PATCH] Show ENFORCED keyword in INFO statement (#4635) --- core/src/sql/statements/define/table.rs | 3 +++ core/src/sql/table_type.rs | 4 ++++ sdk/tests/relate.rs | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/core/src/sql/statements/define/table.rs b/core/src/sql/statements/define/table.rs index 51c6db63..4590887c 100644 --- a/core/src/sql/statements/define/table.rs +++ b/core/src/sql/statements/define/table.rs @@ -203,6 +203,9 @@ impl Display for DefineTableStatement { kind.iter().map(|t| t.0.as_str()).collect::>().join(" | ") )?; } + if rel.enforced { + write!(f, " ENFORCED")?; + } } TableType::Any => { f.write_str(" ANY")?; diff --git a/core/src/sql/table_type.rs b/core/src/sql/table_type.rs index 2901578d..242ea14a 100644 --- a/core/src/sql/table_type.rs +++ b/core/src/sql/table_type.rs @@ -31,6 +31,9 @@ impl Display for TableType { if let Some(kind) = &rel.to { write!(f, " OUT {kind}")?; } + if rel.enforced { + write!(f, " ENFORCED")?; + } } TableType::Any => { f.write_str(" ANY")?; @@ -55,6 +58,7 @@ impl InfoStructure for TableType { tables.into_iter().map(|t| t.0).collect::>().into(), "out".to_string(), if let Some(Kind::Record(tables)) = rel.to => tables.into_iter().map(|t| t.0).collect::>().into(), + "enforced".to_string() => rel.enforced.into() }), } } diff --git a/sdk/tests/relate.rs b/sdk/tests/relate.rs index 67d3bf17..17bf0530 100644 --- a/sdk/tests/relate.rs +++ b/sdk/tests/relate.rs @@ -265,6 +265,7 @@ async fn relate_enforced() -> Result<(), Error> { RELATE a:1->edge:1->a:2; CREATE a:1, a:2; RELATE a:1->edge:1->a:2; + INFO FOR DB; "; let mut t = Test::new(sql).await?; @@ -277,5 +278,20 @@ async fn relate_enforced() -> Result<(), Error> { // t.expect_val("[{ id: edge:1, in: a:1, out: a:2 }]")?; // + let info = Value::parse( + "{ + accesses: {}, + analyzers: {}, + functions: {}, + models: {}, + params: {}, + tables: { + a: 'DEFINE TABLE a TYPE ANY SCHEMALESS PERMISSIONS NONE', + edge: 'DEFINE TABLE edge TYPE RELATION ENFORCED SCHEMALESS PERMISSIONS NONE' + }, + users: {} + }", + ); + t.expect_value(info)?; Ok(()) }