Skip to content

Commit

Permalink
add snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
cvng committed Dec 19, 2023
1 parent b70d26c commit 3da7a50
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/codegen/src/get_node_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,11 @@ fn custom_handlers(node: &Node) -> TokenStream {
"CreateExtensionStmt" => quote! {
tokens.push(TokenProperty::from(Token::Create));
tokens.push(TokenProperty::from(Token::Extension));
if n.if_not_exists {
tokens.push(TokenProperty::from(Token::IfP));
tokens.push(TokenProperty::from(Token::Not));
tokens.push(TokenProperty::from(Token::Exists));
}
},
_ => quote! {},
}
Expand Down
3 changes: 3 additions & 0 deletions crates/parser/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ mod tests {
vec![
TokenProperty::from(SyntaxKind::Create),
TokenProperty::from(SyntaxKind::Extension),
TokenProperty::from(SyntaxKind::IfP),
TokenProperty::from(SyntaxKind::Not),
TokenProperty::from(SyntaxKind::Exists),
TokenProperty::from("x".to_string()),
],
)
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/tests/data/statements/valid/0049.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE EXTENSION x;
CREATE EXTENSION IF NOT EXISTS x CASCADE VERSION \"1.2\" SCHEMA a;
CREATE EXTENSION IF NOT EXISTS x CASCADE VERSION "1.2" SCHEMA a;
28 changes: 28 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: CREATE EXTENSION x;
---
Parse {
cst: SourceFile@0..19
CreateExtensionStmt@0..19
Create@0..6 "CREATE"
Whitespace@6..7 " "
Extension@7..16 "EXTENSION"
Whitespace@16..17 " "
Ident@17..18 "x"
Ascii59@18..19 ";"
,
errors: [],
stmts: [
RawStmt {
stmt: CreateExtensionStmt(
CreateExtensionStmt {
extname: "x",
if_not_exists: false,
options: [],
},
),
range: 0..18,
},
],
}
118 changes: 118 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: "\nCREATE EXTENSION IF NOT EXISTS x CASCADE VERSION \"1.2\" SCHEMA a;"
---
Parse {
cst: SourceFile@0..65
Newline@0..1 "\n"
CreateExtensionStmt@1..65
Create@1..7 "CREATE"
Whitespace@7..8 " "
Extension@8..17 "EXTENSION"
Whitespace@17..18 " "
IfP@18..20 "IF"
Whitespace@20..21 " "
Not@21..24 "NOT"
Whitespace@24..25 " "
Exists@25..31 "EXISTS"
Whitespace@31..32 " "
Ident@32..33 "x"
Whitespace@33..34 " "
DefElem@34..41
Cascade@34..41 "CASCADE"
Whitespace@41..42 " "
DefElem@42..55
VersionP@42..49 "VERSION"
Whitespace@49..50 " "
Ident@50..55 "\"1.2\""
Whitespace@55..56 " "
DefElem@56..64
Schema@56..62 "SCHEMA"
Whitespace@62..63 " "
Ident@63..64 "a"
Ascii59@64..65 ";"
,
errors: [],
stmts: [
RawStmt {
stmt: CreateExtensionStmt(
CreateExtensionStmt {
extname: "x",
if_not_exists: true,
options: [
Node {
node: Some(
DefElem(
DefElem {
defnamespace: "",
defname: "cascade",
arg: Some(
Node {
node: Some(
Boolean(
Boolean {
boolval: true,
},
),
),
},
),
defaction: DefelemUnspec,
location: 33,
},
),
),
},
Node {
node: Some(
DefElem(
DefElem {
defnamespace: "",
defname: "new_version",
arg: Some(
Node {
node: Some(
String(
String {
sval: "1.2",
},
),
),
},
),
defaction: DefelemUnspec,
location: 41,
},
),
),
},
Node {
node: Some(
DefElem(
DefElem {
defnamespace: "",
defname: "schema",
arg: Some(
Node {
node: Some(
String(
String {
sval: "a",
},
),
),
},
),
defaction: DefelemUnspec,
location: 55,
},
),
),
},
],
},
),
range: 0..64,
},
],
}

0 comments on commit 3da7a50

Please sign in to comment.