bugfix: Enforce TYPE RELATION (#3732)

This commit is contained in:
Raphael Darley 2024-03-21 10:59:08 +00:00 committed by GitHub
parent e00c456389
commit ce8e2d4578
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 8 deletions

View file

@ -29,7 +29,7 @@ pub fn table(i: &str) -> IResult<&str, DefineTableStatement> {
let (i, name) = cut(ident)(i)?;
let (i, opts) = many0(table_opts)(i)?;
let (i, _) = expected(
"TYPE, RELATION, DROP, SCHEMALESS, SCHEMAFUL(L), VIEW, CHANGEFEED, PERMISSIONS, or COMMENT",
"TYPE, DROP, SCHEMALESS, SCHEMAFUL(L), VIEW, CHANGEFEED, PERMISSIONS, or COMMENT",
ending::query,
)(i)?;
// Create the base statement
@ -129,7 +129,6 @@ fn table_opts(i: &str) -> IResult<&str, DefineTableOption> {
table_permissions,
table_changefeed,
table_type,
table_relation,
))(i)
}

View file

@ -354,10 +354,6 @@ impl Parser<'_> {
self.pop_peek();
res.drop = true;
}
t!("RELATION") => {
self.pop_peek();
res.kind = TableType::Relation(self.parse_relation_schema()?);
}
t!("TYPE") => {
self.pop_peek();
match self.peek_kind() {

View file

@ -2648,7 +2648,7 @@ async fn redefining_existing_user_with_if_not_exists_should_error() -> Result<()
#[cfg(feature = "sql2")]
async fn define_table_relation() -> Result<(), Error> {
let sql = "
DEFINE TABLE likes RELATION;
DEFINE TABLE likes TYPE RELATION;
CREATE person:raphael, person:tobie;
RELATE person:raphael->likes->person:tobie;
CREATE likes:1;

View file

@ -789,7 +789,7 @@ async fn field_definition_edge_permissions() -> Result<(), Error> {
DEFINE TABLE user SCHEMAFULL;
DEFINE TABLE business SCHEMAFULL;
DEFINE FIELD owner ON TABLE business TYPE record<user>;
DEFINE TABLE contact RELATION SCHEMAFULL PERMISSIONS FOR create WHERE in.owner.id = $auth.id;
DEFINE TABLE contact TYPE RELATION SCHEMAFULL PERMISSIONS FOR create WHERE in.owner.id = $auth.id;
INSERT INTO user (id, name) VALUES (user:one, 'John'), (user:two, 'Lucy');
INSERT INTO business (id, owner) VALUES (business:one, user:one), (business:two, user:two);
";