Show ENFORCED keyword in INFO statement (#4635)

This commit is contained in:
Dave MacLeod 2024-08-29 22:12:23 +09:00 committed by GitHub
parent 9edb956386
commit ba5c1436ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View file

@ -203,6 +203,9 @@ impl Display for DefineTableStatement {
kind.iter().map(|t| t.0.as_str()).collect::<Vec<_>>().join(" | ") kind.iter().map(|t| t.0.as_str()).collect::<Vec<_>>().join(" | ")
)?; )?;
} }
if rel.enforced {
write!(f, " ENFORCED")?;
}
} }
TableType::Any => { TableType::Any => {
f.write_str(" ANY")?; f.write_str(" ANY")?;

View file

@ -31,6 +31,9 @@ impl Display for TableType {
if let Some(kind) = &rel.to { if let Some(kind) = &rel.to {
write!(f, " OUT {kind}")?; write!(f, " OUT {kind}")?;
} }
if rel.enforced {
write!(f, " ENFORCED")?;
}
} }
TableType::Any => { TableType::Any => {
f.write_str(" ANY")?; f.write_str(" ANY")?;
@ -55,6 +58,7 @@ impl InfoStructure for TableType {
tables.into_iter().map(|t| t.0).collect::<Vec<_>>().into(), tables.into_iter().map(|t| t.0).collect::<Vec<_>>().into(),
"out".to_string(), if let Some(Kind::Record(tables)) = rel.to => "out".to_string(), if let Some(Kind::Record(tables)) = rel.to =>
tables.into_iter().map(|t| t.0).collect::<Vec<_>>().into(), tables.into_iter().map(|t| t.0).collect::<Vec<_>>().into(),
"enforced".to_string() => rel.enforced.into()
}), }),
} }
} }

View file

@ -265,6 +265,7 @@ async fn relate_enforced() -> Result<(), Error> {
RELATE a:1->edge:1->a:2; RELATE a:1->edge:1->a:2;
CREATE a:1, a:2; CREATE a:1, a:2;
RELATE a:1->edge:1->a:2; RELATE a:1->edge:1->a:2;
INFO FOR DB;
"; ";
let mut t = Test::new(sql).await?; 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 }]")?; 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(()) Ok(())
} }