File tree Expand file tree Collapse file tree 5 files changed +155
-1
lines changed
snapshots/statements/valid Expand file tree Collapse file tree 5 files changed +155
-1
lines changed Original file line number Diff line number Diff line change @@ -703,6 +703,11 @@ fn custom_handlers(node: &Node) -> TokenStream {
703
703
"CreateExtensionStmt" => quote ! {
704
704
tokens. push( TokenProperty :: from( Token :: Create ) ) ;
705
705
tokens. push( TokenProperty :: from( Token :: Extension ) ) ;
706
+ if n. if_not_exists {
707
+ tokens. push( TokenProperty :: from( Token :: IfP ) ) ;
708
+ tokens. push( TokenProperty :: from( Token :: Not ) ) ;
709
+ tokens. push( TokenProperty :: from( Token :: Exists ) ) ;
710
+ }
706
711
} ,
707
712
_ => quote ! { } ,
708
713
}
Original file line number Diff line number Diff line change @@ -290,6 +290,9 @@ mod tests {
290
290
vec ! [
291
291
TokenProperty :: from( SyntaxKind :: Create ) ,
292
292
TokenProperty :: from( SyntaxKind :: Extension ) ,
293
+ TokenProperty :: from( SyntaxKind :: IfP ) ,
294
+ TokenProperty :: from( SyntaxKind :: Not ) ,
295
+ TokenProperty :: from( SyntaxKind :: Exists ) ,
293
296
TokenProperty :: from( "x" . to_string( ) ) ,
294
297
] ,
295
298
)
Original file line number Diff line number Diff line change 1
1
CREATE EXTENSION x;
2
- CREATE EXTENSION IF NOT EXISTS x CASCADE VERSION \ " 1.2\ " SCHEMA a;
2
+ CREATE EXTENSION IF NOT EXISTS x CASCADE VERSION " 1.2" SCHEMA a;
Original file line number Diff line number Diff line change
1
+ -- -
2
+ source : crates / parser / tests / statement_parser_test .rs
3
+ description : CREATE EXTENSION x ;
4
+ -- -
5
+ Parse {
6
+ cst : SourceFile @0..19
7
+ CreateExtensionStmt @0..19
8
+ Create @0..6 " CREATE"
9
+ Whitespace @6..7 " "
10
+ Extension @7..16 " EXTENSION"
11
+ Whitespace @16..17 " "
12
+ Ident @17..18 " x"
13
+ Ascii59 @18..19 " ;"
14
+ ,
15
+ errors : [],
16
+ stmts : [
17
+ RawStmt {
18
+ stmt: CreateExtensionStmt (
19
+ CreateExtensionStmt {
20
+ extname: " x" ,
21
+ if_not_exists: false ,
22
+ options: [],
23
+ },
24
+ ),
25
+ range: 0..18 ,
26
+ },
27
+ ],
28
+ }
Original file line number Diff line number Diff line change
1
+ -- -
2
+ source : crates / parser / tests / statement_parser_test .rs
3
+ description : " \n CREATE EXTENSION IF NOT EXISTS x CASCADE VERSION \" 1.2\" SCHEMA a;"
4
+ -- -
5
+ Parse {
6
+ cst : SourceFile @0..65
7
+ Newline @0..1 " \n "
8
+ CreateExtensionStmt @1..65
9
+ Create @1..7 " CREATE"
10
+ Whitespace @7..8 " "
11
+ Extension @8..17 " EXTENSION"
12
+ Whitespace @17..18 " "
13
+ IfP @18..20 " IF"
14
+ Whitespace @20..21 " "
15
+ Not @21..24 " NOT"
16
+ Whitespace @24..25 " "
17
+ Exists @25..31 " EXISTS"
18
+ Whitespace @31..32 " "
19
+ Ident @32..33 " x"
20
+ Whitespace @33..34 " "
21
+ DefElem @34..41
22
+ Cascade @34..41 " CASCADE"
23
+ Whitespace @41..42 " "
24
+ DefElem @42..55
25
+ VersionP @42..49 " VERSION"
26
+ Whitespace @49..50 " "
27
+ Ident @50..55 " \" 1.2\" "
28
+ Whitespace @55..56 " "
29
+ DefElem @56..64
30
+ Schema @56..62 " SCHEMA"
31
+ Whitespace @62..63 " "
32
+ Ident @63..64 " a"
33
+ Ascii59 @64..65 " ;"
34
+ ,
35
+ errors : [],
36
+ stmts : [
37
+ RawStmt {
38
+ stmt: CreateExtensionStmt (
39
+ CreateExtensionStmt {
40
+ extname: " x" ,
41
+ if_not_exists: true ,
42
+ options: [
43
+ Node {
44
+ node: Some (
45
+ DefElem (
46
+ DefElem {
47
+ defnamespace: " " ,
48
+ defname: " cascade" ,
49
+ arg: Some (
50
+ Node {
51
+ node: Some (
52
+ Boolean (
53
+ Boolean {
54
+ boolval: true ,
55
+ },
56
+ ),
57
+ ),
58
+ },
59
+ ),
60
+ defaction: DefelemUnspec ,
61
+ location: 33 ,
62
+ },
63
+ ),
64
+ ),
65
+ },
66
+ Node {
67
+ node: Some (
68
+ DefElem (
69
+ DefElem {
70
+ defnamespace: " " ,
71
+ defname: " new_version" ,
72
+ arg: Some (
73
+ Node {
74
+ node: Some (
75
+ String (
76
+ String {
77
+ sval: " 1.2" ,
78
+ },
79
+ ),
80
+ ),
81
+ },
82
+ ),
83
+ defaction: DefelemUnspec ,
84
+ location: 41 ,
85
+ },
86
+ ),
87
+ ),
88
+ },
89
+ Node {
90
+ node: Some (
91
+ DefElem (
92
+ DefElem {
93
+ defnamespace: " " ,
94
+ defname: " schema" ,
95
+ arg: Some (
96
+ Node {
97
+ node: Some (
98
+ String (
99
+ String {
100
+ sval: " a" ,
101
+ },
102
+ ),
103
+ ),
104
+ },
105
+ ),
106
+ defaction: DefelemUnspec ,
107
+ location: 55 ,
108
+ },
109
+ ),
110
+ ),
111
+ },
112
+ ],
113
+ },
114
+ ),
115
+ range: 0..64 ,
116
+ },
117
+ ],
118
+ }
You can’t perform that action at this time.
0 commit comments