diff --git a/crates/squawk_ide/src/classify.rs b/crates/squawk_ide/src/classify.rs index ece1f496..75b5ef0b 100644 --- a/crates/squawk_ide/src/classify.rs +++ b/crates/squawk_ide/src/classify.rs @@ -40,6 +40,7 @@ pub(crate) enum NameRefClass { Procedure, ProcedureCall, PropertyGraph, + PropertyGraphColumn, QualifiedColumn, Role, Routine, @@ -321,6 +322,14 @@ pub(crate) fn classify_name_ref(node: &SyntaxNode) -> Option { return Some(NameRefClass::PropertyGraph); } + if let Some(parent) = node.parent() + && let Some(expr_as_name) = ast::ExprAsName::cast(parent) + && let Some(expr_as_name_list) = ast::ExprAsNameList::cast(expr_as_name.syntax().parent()?) + && ast::Properties::cast(expr_as_name_list.syntax().parent()?).is_some() + { + return Some(NameRefClass::PropertyGraphColumn); + } + // Check for function/procedure reference in CREATE OPERATOR / CREATE AGGREGATE // before the type check for ancestor in node.ancestors() { @@ -372,6 +381,14 @@ pub(crate) fn classify_name_ref(node: &SyntaxNode) -> Option { if ast::Notify::can_cast(ancestor.kind()) || ast::Unlisten::can_cast(ancestor.kind()) { return Some(NameRefClass::Channel); } + if in_column_list + && (ast::VertexTableDef::can_cast(ancestor.kind()) + || ast::EdgeTableDef::can_cast(ancestor.kind()) + || ast::SourceVertexTable::can_cast(ancestor.kind()) + || ast::DestVertexTable::can_cast(ancestor.kind())) + { + return Some(NameRefClass::PropertyGraphColumn); + } if ast::DropTable::can_cast(ancestor.kind()) || ast::DropForeignTable::can_cast(ancestor.kind()) || ast::Truncate::can_cast(ancestor.kind()) diff --git a/crates/squawk_ide/src/expand_selection.rs b/crates/squawk_ide/src/expand_selection.rs index ccef3110..a1569678 100644 --- a/crates/squawk_ide/src/expand_selection.rs +++ b/crates/squawk_ide/src/expand_selection.rs @@ -74,7 +74,6 @@ const DELIMITED_LIST_KINDS: &[SyntaxKind] = &[ SyntaxKind::VARIANT_LIST, SyntaxKind::XML_TABLE_COLUMN_LIST, SyntaxKind::PATH_PATTERN_LIST, - SyntaxKind::PROPERTIES_LIST, ]; pub fn extend_selection(root: &SyntaxNode, range: TextRange) -> TextRange { diff --git a/crates/squawk_ide/src/folding_ranges.rs b/crates/squawk_ide/src/folding_ranges.rs index 1e5ae92b..f1c902e6 100644 --- a/crates/squawk_ide/src/folding_ranges.rs +++ b/crates/squawk_ide/src/folding_ranges.rs @@ -161,8 +161,7 @@ fn fold_kind(kind: SyntaxKind) -> Option { | SyntaxKind::XML_NAMESPACE_LIST | SyntaxKind::XML_TABLE_COLUMN_LIST | SyntaxKind::LABEL_AND_PROPERTIES_LIST - | SyntaxKind::PATH_PATTERN_LIST - | SyntaxKind::PROPERTIES_LIST => Some(FoldKind::List), + | SyntaxKind::PATH_PATTERN_LIST => Some(FoldKind::List), _ => None, } } diff --git a/crates/squawk_ide/src/goto_definition.rs b/crates/squawk_ide/src/goto_definition.rs index 3859792c..de449880 100644 --- a/crates/squawk_ide/src/goto_definition.rs +++ b/crates/squawk_ide/src/goto_definition.rs @@ -190,6 +190,7 @@ impl From for LocationKind { NameRefClass::Policy => LocationKind::Policy, NameRefClass::PreparedStatement => LocationKind::PreparedStatement, NameRefClass::PropertyGraph => LocationKind::PropertyGraph, + NameRefClass::PropertyGraphColumn => LocationKind::Column, NameRefClass::Role => LocationKind::Role, NameRefClass::Schema => LocationKind::Schema, NameRefClass::Sequence => LocationKind::Sequence, @@ -9383,6 +9384,317 @@ create property graph g "); } + #[test] + fn goto_create_property_graph_sources_table() { + assert_snapshot!(goto(" +create table v1 ( + id int8 primary key, + name text +); + +create table v2 ( + id int8 primary key, + name text +); + +create table v3 ( + id int8 primary key, + name text +); + +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create table e2 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v3 +); + +create property graph g1 + vertex tables (v1, v2, v3) + edge tables ( + e1 source v1$0 destination v2, + e2 source v1 destination v3); +"), @" + ╭▸ + 2 │ create table v1 ( + │ ── 2. destination + ‡ + 32 │ e1 source v1 destination v2, + ╰╴ ─ 1. source + " + ); + + assert_snapshot!(goto(" +create table v1 ( + id int8 primary key, + name text +); + +create table v2 ( + id int8 primary key, + name text +); + +create table v3 ( + id int8 primary key, + name text +); + +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create table e2 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v3 +); + +create property graph g1 + vertex tables (v1, v2, v3) + edge tables ( + e1 source v1 destination v2, + e2 source v1 destination v3$0); +"), @" + ╭▸ + 12 │ create table v3 ( + │ ── 2. destination + ‡ + 33 │ e2 source v1 destination v3); + ╰╴ ─ 1. source + " + ); + } + + #[test] + fn goto_create_property_graph_references_table() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 + source key (source_id) references v1$0 (id) + destination key (destination_id) references v2 (id) + ); +"), @" + ╭▸ + 2 │ create table v1 (id int8 primary key); + │ ── 2. destination + ‡ + 14 │ source key (source_id) references v1 (id) + ╰╴ ─ 1. source + " + ); + } + + #[test] + fn goto_create_property_graph_vertex_key_column() { + assert_snapshot!(goto(" +create table v1 ( + id int8 primary key, + name text +); + +create property graph g1 + vertex tables (v1 key (id$0)); +"), @" + ╭▸ + 3 │ id int8 primary key, + │ ── 2. destination + ‡ + 8 │ vertex tables (v1 key (id)); + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_edge_source_key_column() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 key (id) + source key (source_id$0) references v1 (id) + destination key (destination_id) references v2 (id)); +"), @" + ╭▸ + 6 │ source_id int8 references v1, + │ ───────── 2. destination + ‡ + 14 │ source key (source_id) references v1 (id) + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_edge_source_references_column() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 key (id) + source key (source_id) references v1 (id$0) + destination key (destination_id) references v2 (id)); +"), @" + ╭▸ + 2 │ create table v1 (id int8 primary key); + │ ── 2. destination + ‡ + 14 │ source key (source_id) references v1 (id) + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_edge_destination_key_column() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 key (id) + source key (source_id) references v1 (id) + destination key (destination_id$0) references v2 (id)); +"), @" + ╭▸ + 7 │ destination_id int8 references v2 + │ ────────────── 2. destination + ‡ + 15 │ destination key (destination_id) references v2 (id)); + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_edge_destination_references_column() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 key (id) + source key (source_id) references v1 (id) + destination key (destination_id) references v2 (id$0)); +"), @" + ╭▸ + 3 │ create table v2 (id int8 primary key); + │ ── 2. destination + ‡ + 15 │ destination key (destination_id) references v2 (id)); + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_vertex_properties_column() { + assert_snapshot!(goto(" +create table v1 ( + id int8 primary key, + name text +); + +create property graph g1 + vertex tables (v1 properties (id$0, name)); +"), @" + ╭▸ + 3 │ id int8 primary key, + │ ── 2. destination + ‡ + 8 │ vertex tables (v1 properties (id, name)); + ╰╴ ─ 1. source + "); + + assert_snapshot!(goto(" +create table v1 ( + id int8 primary key, + name text +); + +create property graph g1 + vertex tables (v1 properties (id, nam$0e)); +"), @" + ╭▸ + 4 │ name text + │ ──── 2. destination + ‡ + 8 │ vertex tables (v1 properties (id, name)); + ╰╴ ─ 1. source + "); + } + + #[test] + fn goto_create_property_graph_edge_properties_column() { + assert_snapshot!(goto(" +create table v1 (id int8 primary key); +create table v2 (id int8 primary key); +create table e1 ( + id int8 primary key, + source_id int8 references v1, + destination_id int8 references v2 +); + +create property graph g1 + vertex tables (v1, v2) + edge tables ( + e1 + source v1 + destination v2 + properties (id, source_id$0, destination_id)); +"), @" + ╭▸ + 6 │ source_id int8 references v1, + │ ───────── 2. destination + ‡ + 16 │ properties (id, source_id, destination_id)); + ╰╴ ─ 1. source + "); + } + #[test] fn goto_drop_property_graph() { assert_snapshot!(goto(" diff --git a/crates/squawk_ide/src/hover.rs b/crates/squawk_ide/src/hover.rs index 169a7606..46752e25 100644 --- a/crates/squawk_ide/src/hover.rs +++ b/crates/squawk_ide/src/hover.rs @@ -290,6 +290,7 @@ fn hover_name_ref( NameRefClass::Channel => hover_channel(root, name_ref, binder), NameRefClass::Window => hover_window(root, name_ref, binder), NameRefClass::PropertyGraph => hover_property_graph(root, name_ref, binder), + NameRefClass::PropertyGraphColumn => hover_column(root, name_ref, binder), } } diff --git a/crates/squawk_ide/src/resolve.rs b/crates/squawk_ide/src/resolve.rs index 1a4f4c4e..62281669 100644 --- a/crates/squawk_ide/src/resolve.rs +++ b/crates/squawk_ide/src/resolve.rs @@ -553,6 +553,12 @@ pub(crate) fn resolve_name_ref( .map(|ptr| (smallvec![ptr], LocationKind::Table)), NameRefClass::JoinUsingColumn => resolve_join_using_columns(binder, root, name_ref) .map(|ptrs| (ptrs, LocationKind::Column)), + NameRefClass::PropertyGraphColumn => { + resolve_property_graph_column_ptr(binder, root, name_ref).map(|ptr| { + let kind = resolved_location_kind(root, &ptr, LocationKind::Column); + (smallvec![ptr], kind) + }) + } NameRefClass::AlterColumn => { let column_name = Name::from_node(name_ref); let alter_table = name_ref @@ -907,6 +913,54 @@ fn resolve_create_index_column_ptr( resolve_column_for_path(binder, root, &path, column_name) } +fn resolve_property_graph_column_ptr( + binder: &Binder, + root: &SyntaxNode, + column_name_ref: &ast::NameRef, +) -> Option { + let column_name = Name::from_node(column_name_ref); + let parent = column_name_ref.syntax().parent()?; + + if let Some(column) = ast::Column::cast(parent.clone()) + && let Some(column_list) = ast::ColumnList::cast(column.syntax().parent()?) + { + if let Some(references_table) = ast::ReferencesTable::cast(column_list.syntax().parent()?) { + let table_name = Name::from_node(&references_table.name_ref()?); + let position = column_name_ref.syntax().text_range().start(); + return resolve_column_for_table( + binder, + root, + &table_name, + &None, + &column_name, + position, + ); + } else if let Some(edge_table_def) = column_list + .syntax() + .ancestors() + .find_map(ast::EdgeTableDef::cast) + { + return resolve_column_for_path(binder, root, &edge_table_def.path()?, column_name); + } else if let Some(vertex_table_def) = + ast::VertexTableDef::cast(column_list.syntax().parent()?) + { + return resolve_column_for_path(binder, root, &vertex_table_def.path()?, column_name); + } + } else if let Some(expr_as_name) = ast::ExprAsName::cast(parent) + && let Some(expr_as_name_list) = ast::ExprAsNameList::cast(expr_as_name.syntax().parent()?) + && let Some(properties) = ast::Properties::cast(expr_as_name_list.syntax().parent()?) + { + let parent = properties.syntax().parent()?; + if let Some(edge) = ast::EdgeTableDef::cast(parent.clone()) { + return resolve_column_for_path(binder, root, &edge.path()?, column_name); + } else if let Some(vertex) = ast::VertexTableDef::cast(parent) { + return resolve_column_for_path(binder, root, &vertex.path()?, column_name); + } + } + + None +} + fn resolve_column_for_path( binder: &Binder, root: &SyntaxNode, @@ -1072,8 +1126,11 @@ fn extract_table_schema_from_path(path: &ast::Path) -> Option<(Name, Option Option<(Name, Option)> { - let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?; - extract_table_schema_from_path(&path) + if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { + return extract_table_schema_from_path(&path); + } + + Some((Name::from_node(name_ref), None)) } fn resolve_select_qualified_column_ptr( diff --git a/crates/squawk_parser/src/generated/syntax_kind.rs b/crates/squawk_parser/src/generated/syntax_kind.rs index 46b37a91..e687aea3 100644 --- a/crates/squawk_parser/src/generated/syntax_kind.rs +++ b/crates/squawk_parser/src/generated/syntax_kind.rs @@ -1060,7 +1060,7 @@ pub enum SyntaxKind { PRIMARY_KEY_CONSTRAINT, PRIVILEGES, PRIVILEGE_TARGET, - PROPERTIES_LIST, + PROPERTIES, PUBLICATION_OBJECT, READ_COMMITTED, READ_ONLY, @@ -1068,6 +1068,7 @@ pub enum SyntaxKind { READ_WRITE, REASSIGN, REFERENCES_CONSTRAINT, + REFERENCES_TABLE, REFERENCING, REFERENCING_TABLE, REFRESH, diff --git a/crates/squawk_parser/src/grammar.rs b/crates/squawk_parser/src/grammar.rs index 1829612a..cca950f4 100644 --- a/crates/squawk_parser/src/grammar.rs +++ b/crates/squawk_parser/src/grammar.rs @@ -3626,6 +3626,7 @@ fn opt_sequence_options(p: &mut Parser<'_>) -> Option { } } +#[derive(Clone, Copy)] enum ColumnDefKind { Name, NameRef, @@ -3654,7 +3655,7 @@ fn opt_column_list_with(p: &mut Parser<'_>, kind: ColumnDefKind) -> bool { if !p.at_ts(COLUMN_FIRST) { break; } - column(p, &kind); + column(p, kind); if p.at(COMMA) && p.nth_at(1, R_PAREN) { p.err_and_bump("unexpected trailing comma"); } @@ -3672,7 +3673,7 @@ fn opt_column_list_with(p: &mut Parser<'_>, kind: ColumnDefKind) -> bool { return true; } -fn column(p: &mut Parser<'_>, kind: &ColumnDefKind) -> CompletedMarker { +fn column(p: &mut Parser<'_>, kind: ColumnDefKind) -> CompletedMarker { assert!(p.at_ts(COLUMN_FIRST)); let m = p.start(); match kind { @@ -8534,7 +8535,7 @@ fn opt_vertex_table_def(p: &mut Parser<'_>) -> bool { fn opt_key_columns(p: &mut Parser<'_>) { if p.eat(KEY_KW) { - opt_column_list_with(p, ColumnDefKind::Name); + opt_column_list_with(p, ColumnDefKind::NameRef); } } @@ -8583,7 +8584,7 @@ fn opt_element_table_properties_clause(p: &mut Parser<'_>) -> bool { ALL_PROPERTIES } else { expr_as_name_list(p); - PROPERTIES_LIST + PROPERTIES } }; m.complete(p, kind); @@ -8631,18 +8632,24 @@ fn opt_edge_table_def(p: &mut Parser<'_>) -> bool { true } +fn references_table(p: &mut Parser<'_>) { + let m = p.start(); + p.expect(REFERENCES_KW); + name_ref(p); + opt_column_list_with(p, ColumnDefKind::NameRef); + m.complete(p, REFERENCES_TABLE); +} + // SOURCE KEY (a, b) REFERENCES t (c, d) // SOURCE t fn source_vertex_table(p: &mut Parser<'_>) { let m = p.start(); p.expect(SOURCE_KW); if p.eat(KEY_KW) { - opt_column_list_with(p, ColumnDefKind::Name); - p.expect(REFERENCES_KW); - name_ref(p); - opt_column_list_with(p, ColumnDefKind::Name); + opt_column_list_with(p, ColumnDefKind::NameRef); + references_table(p); } else { - name(p); + name_ref(p); } m.complete(p, SOURCE_VERTEX_TABLE); } @@ -8653,12 +8660,10 @@ fn dest_vertex_table(p: &mut Parser<'_>) { let m = p.start(); p.expect(DESTINATION_KW); if p.eat(KEY_KW) { - opt_column_list_with(p, ColumnDefKind::Name); - p.expect(REFERENCES_KW); - name_ref(p); - opt_column_list_with(p, ColumnDefKind::Name); + opt_column_list_with(p, ColumnDefKind::NameRef); + references_table(p); } else { - name(p); + name_ref(p); } m.complete(p, DEST_VERTEX_TABLE); } @@ -13179,7 +13184,7 @@ fn opt_set_column(p: &mut Parser<'_>) -> Option { Some(m.complete(p, SET_MULTIPLE_COLUMNS)) } else { // column_name = { expression | DEFAULT } - column(p, &ColumnDefKind::NameRef); + column(p, ColumnDefKind::NameRef); p.expect(EQ); set_expr(p); Some(m.complete(p, SET_SINGLE_COLUMN)) diff --git a/crates/squawk_parser/tests/snapshots/tests__alter_property_graph_ok.snap b/crates/squawk_parser/tests/snapshots/tests__alter_property_graph_ok.snap index 366e6418..ff572603 100644 --- a/crates/squawk_parser/tests/snapshots/tests__alter_property_graph_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__alter_property_graph_ok.snap @@ -148,12 +148,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "c" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "k" R_PAREN ")" COMMA "," @@ -169,12 +169,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "l" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "u" R_PAREN ")" WHITESPACE " \n " @@ -205,12 +205,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "x" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "y" R_PAREN ")" WHITESPACE "\n " @@ -222,21 +222,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "s" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "k" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "references" + WHITESPACE " " + NAME_REF + IDENT "k" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "id" + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" @@ -246,21 +247,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "d" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "k" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "references" + WHITESPACE " " + NAME_REF + IDENT "k" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "id" + R_PAREN ")" WHITESPACE "\n " LABEL_AND_PROPERTIES_LIST LABEL_AND_PROPERTIES @@ -269,7 +271,7 @@ SOURCE_FILE NAME IDENT "q" WHITESPACE " " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "properties" WHITESPACE " " EXPR_AS_NAME_LIST @@ -301,7 +303,7 @@ SOURCE_FILE NAME IDENT "q" WHITESPACE " " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "properties" WHITESPACE " " EXPR_AS_NAME_LIST @@ -359,7 +361,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "l" R_PAREN ")" WHITESPACE " \n " @@ -392,12 +394,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "x" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "y" R_PAREN ")" WHITESPACE "\n " @@ -409,21 +411,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "s" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "k" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "references" + WHITESPACE " " + NAME_REF + IDENT "k" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "id" + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" @@ -433,21 +436,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "d" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "k" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "references" + WHITESPACE " " + NAME_REF + IDENT "k" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "id" + R_PAREN ")" WHITESPACE "\n " R_PAREN ")" SEMICOLON ";" diff --git a/crates/squawk_parser/tests/snapshots/tests__create_property_graph_ok.snap b/crates/squawk_parser/tests/snapshots/tests__create_property_graph_ok.snap index 33e6771a..183294b6 100644 --- a/crates/squawk_parser/tests/snapshots/tests__create_property_graph_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__create_property_graph_ok.snap @@ -192,12 +192,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "a" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "b" R_PAREN ")" WHITESPACE " " @@ -234,12 +234,12 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "x" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "y" R_PAREN ")" WHITESPACE "\n " @@ -251,31 +251,32 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "a" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "b" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "k" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "t" - COMMA "," + REFERENCES_TABLE + REFERENCES_KW "references" WHITESPACE " " - COLUMN - NAME - IDENT "y" - R_PAREN ")" + NAME_REF + IDENT "k" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "t" + COMMA "," + WHITESPACE " " + COLUMN + NAME_REF + IDENT "y" + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" @@ -285,31 +286,32 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "q" COMMA "," WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "t" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "references" - WHITESPACE " " - NAME_REF - IDENT "a" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "r" - COMMA "," + REFERENCES_TABLE + REFERENCES_KW "references" WHITESPACE " " - COLUMN - NAME - IDENT "j" - R_PAREN ")" + NAME_REF + IDENT "a" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "r" + COMMA "," + WHITESPACE " " + COLUMN + NAME_REF + IDENT "j" + R_PAREN ")" WHITESPACE "\n " ALL_PROPERTIES PROPERTIES_KW "properties" @@ -347,13 +349,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "s" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "d" WHITESPACE "\n " NO_PROPERTIES @@ -390,16 +392,16 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "s" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "d" WHITESPACE "\n " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "properties" WHITESPACE " " EXPR_AS_NAME_LIST @@ -474,13 +476,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "z" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "y" WHITESPACE "\n " R_PAREN ")" @@ -516,13 +518,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "z" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "y" WHITESPACE "\n " R_PAREN ")" @@ -558,13 +560,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "z" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "y" WHITESPACE "\n " R_PAREN ")" @@ -625,13 +627,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "z" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "y" COMMA "," WHITESPACE "\n " @@ -644,13 +646,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "source" WHITESPACE " " - NAME + NAME_REF IDENT "z" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "destination" WHITESPACE " " - NAME + NAME_REF IDENT "y" WHITESPACE "\n " R_PAREN ")" diff --git a/crates/squawk_parser/tests/snapshots/tests__sql_pgq_ok.snap b/crates/squawk_parser/tests/snapshots/tests__sql_pgq_ok.snap index 2eb37526..6292ad04 100644 --- a/crates/squawk_parser/tests/snapshots/tests__sql_pgq_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__sql_pgq_ok.snap @@ -406,13 +406,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "SOURCE" WHITESPACE " " - NAME + NAME_REF IDENT "orders" WHITESPACE " " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "products" COMMA "," WHITESPACE "\n " @@ -425,13 +425,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "SOURCE" WHITESPACE " " - NAME + NAME_REF IDENT "customers" WHITESPACE " " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "orders" WHITESPACE "\n " R_PAREN ")" @@ -647,7 +647,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "product_no" R_PAREN ")" COMMA "," @@ -663,7 +663,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "customer_id" R_PAREN ")" COMMA "," @@ -679,7 +679,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "order_id" R_PAREN ")" WHITESPACE "\n " @@ -703,7 +703,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "order_items_id" R_PAREN ")" WHITESPACE "\n " @@ -715,21 +715,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "order_id" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "orders" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "order_id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" + WHITESPACE " " + NAME_REF + IDENT "orders" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "order_id" + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" @@ -739,21 +740,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "product_no" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "products" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "product_no" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" + WHITESPACE " " + NAME_REF + IDENT "products" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "product_no" + R_PAREN ")" COMMA "," WHITESPACE "\n " EDGE_TABLE_DEF @@ -767,7 +769,7 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "customer_orders_id" R_PAREN ")" WHITESPACE "\n " @@ -779,21 +781,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "customer_id" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "customers" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "customer_id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" + WHITESPACE " " + NAME_REF + IDENT "customers" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "customer_id" + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" @@ -803,21 +806,22 @@ SOURCE_FILE COLUMN_LIST L_PAREN "(" COLUMN - NAME + NAME_REF IDENT "order_id" R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "orders" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" - COLUMN - NAME - IDENT "order_id" - R_PAREN ")" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" + WHITESPACE " " + NAME_REF + IDENT "orders" + WHITESPACE " " + COLUMN_LIST + L_PAREN "(" + COLUMN + NAME_REF + IDENT "order_id" + R_PAREN ")" WHITESPACE "\n " R_PAREN ")" SEMICOLON ";" @@ -900,13 +904,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "SOURCE" WHITESPACE " " - NAME + NAME_REF IDENT "orders" WHITESPACE " " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "products" WHITESPACE " " LABEL_AND_PROPERTIES_LIST @@ -926,13 +930,13 @@ SOURCE_FILE SOURCE_VERTEX_TABLE SOURCE_KW "SOURCE" WHITESPACE " " - NAME + NAME_REF IDENT "customers" WHITESPACE " " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "orders" WHITESPACE " " LABEL_AND_PROPERTIES_LIST @@ -1467,7 +1471,7 @@ SOURCE_FILE NAME IDENT "Person" WHITESPACE " " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "PROPERTIES" WHITESPACE " " EXPR_AS_NAME_LIST @@ -1493,7 +1497,7 @@ SOURCE_FILE NAME IDENT "Company" WHITESPACE " " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "PROPERTIES" WHITESPACE " " EXPR_AS_NAME_LIST @@ -1519,7 +1523,7 @@ SOURCE_FILE NAME IDENT "Account" WHITESPACE " " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "PROPERTIES" WHITESPACE " " EXPR_AS_NAME_LIST @@ -1555,24 +1559,25 @@ SOURCE_FILE L_PAREN "(" WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "from_account" WHITESPACE " " R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "Accounts" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" WHITESPACE " " - COLUMN - NAME - IDENT "number" + NAME_REF + IDENT "Accounts" WHITESPACE " " - R_PAREN ")" + COLUMN_LIST + L_PAREN "(" + WHITESPACE " " + COLUMN + NAME_REF + IDENT "number" + WHITESPACE " " + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" @@ -1583,24 +1588,25 @@ SOURCE_FILE L_PAREN "(" WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "to_account" WHITESPACE " " R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "Accounts" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" WHITESPACE " " - COLUMN - NAME - IDENT "number" + NAME_REF + IDENT "Accounts" WHITESPACE " " - R_PAREN ")" + COLUMN_LIST + L_PAREN "(" + WHITESPACE " " + COLUMN + NAME_REF + IDENT "number" + WHITESPACE " " + R_PAREN ")" WHITESPACE "\n " LABEL_AND_PROPERTIES_LIST LABEL_AND_PROPERTIES @@ -1609,7 +1615,7 @@ SOURCE_FILE NAME TRANSACTION_KW "transaction" WHITESPACE "\n " - PROPERTIES_LIST + PROPERTIES PROPERTIES_KW "PROPERTIES" WHITESPACE " " EXPR_AS_NAME_LIST @@ -1642,29 +1648,30 @@ SOURCE_FILE L_PAREN "(" WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "number" WHITESPACE " " R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "Accounts" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" WHITESPACE " " - COLUMN - NAME - IDENT "number" + NAME_REF + IDENT "Accounts" WHITESPACE " " - R_PAREN ")" + COLUMN_LIST + L_PAREN "(" + WHITESPACE " " + COLUMN + NAME_REF + IDENT "number" + WHITESPACE " " + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "Persons" WHITESPACE "\n " LABEL_AND_PROPERTIES_LIST @@ -1700,29 +1707,30 @@ SOURCE_FILE L_PAREN "(" WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "number" WHITESPACE " " R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "Accounts" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" WHITESPACE " " - COLUMN - NAME - IDENT "number" + NAME_REF + IDENT "Accounts" WHITESPACE " " - R_PAREN ")" + COLUMN_LIST + L_PAREN "(" + WHITESPACE " " + COLUMN + NAME_REF + IDENT "number" + WHITESPACE " " + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "Companies" WHITESPACE "\n " LABEL_AND_PROPERTIES_LIST @@ -1758,29 +1766,30 @@ SOURCE_FILE L_PAREN "(" WHITESPACE " " COLUMN - NAME + NAME_REF IDENT "id" WHITESPACE " " R_PAREN ")" WHITESPACE " " - REFERENCES_KW "REFERENCES" - WHITESPACE " " - NAME_REF - IDENT "Persons" - WHITESPACE " " - COLUMN_LIST - L_PAREN "(" + REFERENCES_TABLE + REFERENCES_KW "REFERENCES" WHITESPACE " " - COLUMN - NAME - IDENT "id" + NAME_REF + IDENT "Persons" WHITESPACE " " - R_PAREN ")" + COLUMN_LIST + L_PAREN "(" + WHITESPACE " " + COLUMN + NAME_REF + IDENT "id" + WHITESPACE " " + R_PAREN ")" WHITESPACE "\n " DEST_VERTEX_TABLE DESTINATION_KW "DESTINATION" WHITESPACE " " - NAME + NAME_REF IDENT "Companies" WHITESPACE "\n " NO_PROPERTIES diff --git a/crates/squawk_syntax/src/ast/generated/nodes.rs b/crates/squawk_syntax/src/ast/generated/nodes.rs index 4b81df93..fa1877b8 100644 --- a/crates/squawk_syntax/src/ast/generated/nodes.rs +++ b/crates/squawk_syntax/src/ast/generated/nodes.rs @@ -5982,6 +5982,10 @@ impl DestVertexTable { support::child(&self.syntax) } #[inline] + pub fn references_table(&self) -> Option { + support::child(&self.syntax) + } + #[inline] pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, SyntaxKind::L_PAREN) } @@ -5997,10 +6001,6 @@ impl DestVertexTable { pub fn key_token(&self) -> Option { support::token(&self.syntax, SyntaxKind::KEY_KW) } - #[inline] - pub fn references_token(&self) -> Option { - support::token(&self.syntax, SyntaxKind::REFERENCES_KW) - } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -13802,10 +13802,10 @@ impl Privileges { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct PropertiesList { +pub struct Properties { pub(crate) syntax: SyntaxNode, } -impl PropertiesList { +impl Properties { #[inline] pub fn expr_as_name_list(&self) -> Option { support::child(&self.syntax) @@ -14033,6 +14033,33 @@ impl ReferencesConstraint { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ReferencesTable { + pub(crate) syntax: SyntaxNode, +} +impl ReferencesTable { + #[inline] + pub fn column_list(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn name_ref(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn l_paren_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::L_PAREN) + } + #[inline] + pub fn r_paren_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::R_PAREN) + } + #[inline] + pub fn references_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::REFERENCES_KW) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Referencing { pub(crate) syntax: SyntaxNode, @@ -16411,6 +16438,10 @@ impl SourceVertexTable { support::child(&self.syntax) } #[inline] + pub fn references_table(&self) -> Option { + support::child(&self.syntax) + } + #[inline] pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, SyntaxKind::L_PAREN) } @@ -16423,10 +16454,6 @@ impl SourceVertexTable { support::token(&self.syntax, SyntaxKind::KEY_KW) } #[inline] - pub fn references_token(&self) -> Option { - support::token(&self.syntax, SyntaxKind::REFERENCES_KW) - } - #[inline] pub fn source_token(&self) -> Option { support::token(&self.syntax, SyntaxKind::SOURCE_KW) } @@ -18570,7 +18597,7 @@ pub enum ElementTableLabelAndProperties { pub enum ElementTableProperties { AllProperties(AllProperties), NoProperties(NoProperties), - PropertiesList(PropertiesList), + Properties(Properties), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -27948,10 +27975,10 @@ impl AstNode for Privileges { &self.syntax } } -impl AstNode for PropertiesList { +impl AstNode for Properties { #[inline] fn can_cast(kind: SyntaxKind) -> bool { - kind == SyntaxKind::PROPERTIES_LIST + kind == SyntaxKind::PROPERTIES } #[inline] fn cast(syntax: SyntaxNode) -> Option { @@ -28092,6 +28119,24 @@ impl AstNode for ReferencesConstraint { &self.syntax } } +impl AstNode for ReferencesTable { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::REFERENCES_TABLE + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} impl AstNode for Referencing { #[inline] fn can_cast(kind: SyntaxKind) -> bool { @@ -32920,7 +32965,7 @@ impl AstNode for ElementTableProperties { fn can_cast(kind: SyntaxKind) -> bool { matches!( kind, - SyntaxKind::ALL_PROPERTIES | SyntaxKind::NO_PROPERTIES | SyntaxKind::PROPERTIES_LIST + SyntaxKind::ALL_PROPERTIES | SyntaxKind::NO_PROPERTIES | SyntaxKind::PROPERTIES ) } #[inline] @@ -32932,9 +32977,7 @@ impl AstNode for ElementTableProperties { SyntaxKind::NO_PROPERTIES => { ElementTableProperties::NoProperties(NoProperties { syntax }) } - SyntaxKind::PROPERTIES_LIST => { - ElementTableProperties::PropertiesList(PropertiesList { syntax }) - } + SyntaxKind::PROPERTIES => ElementTableProperties::Properties(Properties { syntax }), _ => { return None; } @@ -32946,7 +32989,7 @@ impl AstNode for ElementTableProperties { match self { ElementTableProperties::AllProperties(it) => &it.syntax, ElementTableProperties::NoProperties(it) => &it.syntax, - ElementTableProperties::PropertiesList(it) => &it.syntax, + ElementTableProperties::Properties(it) => &it.syntax, } } } @@ -32962,10 +33005,10 @@ impl From for ElementTableProperties { ElementTableProperties::NoProperties(node) } } -impl From for ElementTableProperties { +impl From for ElementTableProperties { #[inline] - fn from(node: PropertiesList) -> ElementTableProperties { - ElementTableProperties::PropertiesList(node) + fn from(node: Properties) -> ElementTableProperties { + ElementTableProperties::Properties(node) } } impl AstNode for ExplainStmt { diff --git a/crates/squawk_syntax/src/postgresql.ungram b/crates/squawk_syntax/src/postgresql.ungram index 388a8aa1..40a802ce 100644 --- a/crates/squawk_syntax/src/postgresql.ungram +++ b/crates/squawk_syntax/src/postgresql.ungram @@ -2335,7 +2335,7 @@ ElementTableLabelAndProperties = ElementTableProperties = NoProperties | AllProperties -| PropertiesList +| Properties NoProperties = 'no' 'properties' @@ -2343,7 +2343,7 @@ NoProperties = AllProperties = 'properties' 'all' 'columns' -PropertiesList = +Properties = 'properties' '(' ExprAsNameList ')' LabelAndPropertiesList = @@ -2369,11 +2369,15 @@ EdgeTableDef = SourceVertexTable = 'source' NameRef -| 'source' 'key' '(' ColumnList ')' 'references' NameRef '(' ColumnList ')' +| 'source' 'key' '(' ColumnList ')' ReferencesTable + + +ReferencesTable = + 'references' NameRef '(' ColumnList ')' DestVertexTable = 'destination' NameRef -| 'destination' 'key' '(' ColumnList ')' 'references' NameRef '(' ColumnList ')' +| 'destination' 'key' '(' ColumnList ')' ReferencesTable AlterPropertyGraph = 'alter' 'property' 'graph' IfExists? Path