@@ -57,29 +57,27 @@ pub mod test_utils {
57
57
#[ cfg( test) ]
58
58
mod analyze_statements_tests {
59
59
use crate :: ast:: AnalyzeStatement ;
60
- use crate :: parser:: errors:: ParsingError ;
61
- use crate :: parser:: test_utils:: {
62
- assert_statements_equal, run_rainy_day_test, run_sunny_day_test,
63
- } ;
60
+ use crate :: parser:: test_utils:: { assert_statements_equal, run_sunny_day_test} ;
64
61
use crate :: { Parser , Statement } ;
65
62
66
63
use super :: test_utils:: analyze_statement;
67
64
68
65
#[ test]
69
- fn test_analyze_basic ( ) {
66
+ fn analyze_test ( ) {
70
67
run_sunny_day_test ( "ANALYZE;" , Statement :: Analyze ( analyze_statement ( ) ) ) ;
71
68
}
72
69
73
70
#[ test]
74
- fn test_analyze_with_schema_name ( ) {
71
+ fn analyze_schema ( ) {
75
72
let mut expected_statement = analyze_statement ( ) ;
76
73
expected_statement. schema_name = Some ( "main" . to_string ( ) ) ;
77
74
75
+ // If we have only one identifier, it's a schema name
78
76
run_sunny_day_test ( "ANALYZE main;" , Statement :: Analyze ( expected_statement) ) ;
79
77
}
80
78
81
79
#[ test]
82
- fn test_analyze_with_schema_and_table ( ) {
80
+ fn analyze_with_schema_and_table ( ) {
83
81
let mut expected_statement = analyze_statement ( ) ;
84
82
expected_statement. schema_name = Some ( "main" . to_string ( ) ) ;
85
83
expected_statement. table_or_index_name = Some ( "my_table" . to_string ( ) ) ;
@@ -91,23 +89,23 @@ mod analyze_statements_tests {
91
89
}
92
90
93
91
#[ test]
94
- fn test_analyze_with_single_quoted_schema ( ) {
92
+ fn analyze_with_single_quoted_schema ( ) {
95
93
let mut expected_statement = analyze_statement ( ) ;
96
94
expected_statement. schema_name = Some ( "'main'" . to_string ( ) ) ;
97
95
98
96
run_sunny_day_test ( "ANALYZE 'main';" , Statement :: Analyze ( expected_statement) ) ;
99
97
}
100
98
101
99
#[ test]
102
- fn test_analyze_with_double_quoted_schema ( ) {
100
+ fn analyze_with_double_quoted_schema ( ) {
103
101
let mut expected_statement = analyze_statement ( ) ;
104
102
expected_statement. schema_name = Some ( "\" main\" " . to_string ( ) ) ;
105
103
106
104
run_sunny_day_test ( "ANALYZE \" main\" ;" , Statement :: Analyze ( expected_statement) ) ;
107
105
}
108
106
109
107
#[ test]
110
- fn test_analyze_with_single_quoted_schema_and_table ( ) {
108
+ fn analyze_with_single_quoted_schema_and_table ( ) {
111
109
let mut expected_statement = analyze_statement ( ) ;
112
110
expected_statement. schema_name = Some ( "'main'" . to_string ( ) ) ;
113
111
expected_statement. table_or_index_name = Some ( "'my_table'" . to_string ( ) ) ;
@@ -119,7 +117,7 @@ mod analyze_statements_tests {
119
117
}
120
118
121
119
#[ test]
122
- fn test_analyze_with_double_quoted_schema_and_table ( ) {
120
+ fn analyze_with_double_quoted_schema_and_table ( ) {
123
121
let mut expected_statement = analyze_statement ( ) ;
124
122
expected_statement. schema_name = Some ( "\" main\" " . to_string ( ) ) ;
125
123
expected_statement. table_or_index_name = Some ( "\" my_table\" " . to_string ( ) ) ;
@@ -131,29 +129,13 @@ mod analyze_statements_tests {
131
129
}
132
130
133
131
#[ test]
134
- fn test_analyze_missing_semicolon ( ) {
132
+ fn analyze_missing_semicolon ( ) {
135
133
let sql = "ANALYZE" ;
136
134
run_sunny_day_test ( sql, Statement :: Analyze ( analyze_statement ( ) ) ) ;
137
135
}
138
136
139
137
#[ test]
140
- fn test_analyze_with_invalid_schema_name ( ) {
141
- run_rainy_day_test (
142
- "ANALYZE 'unclosed_schema;" ,
143
- ParsingError :: TokenizerError ( "UnterminatedLiteral: 'unclosed_schema;" . into ( ) ) ,
144
- ) ;
145
- }
146
-
147
- #[ test]
148
- fn test_analyze_with_invalid_table_name ( ) {
149
- run_rainy_day_test (
150
- "ANALYZE main.'unclosed_table;" ,
151
- ParsingError :: TokenizerError ( "UnterminatedLiteral: 'unclosed_table;" . into ( ) ) ,
152
- ) ;
153
- }
154
-
155
- #[ test]
156
- fn test_analyze_with_numeric_schema_name ( ) {
138
+ fn analyze_numeric_schema_name ( ) {
157
139
run_sunny_day_test (
158
140
"ANALYZE '123';" ,
159
141
Statement :: Analyze ( AnalyzeStatement {
@@ -164,7 +146,7 @@ mod analyze_statements_tests {
164
146
}
165
147
166
148
#[ test]
167
- fn test_analyze_with_numeric_table_name ( ) {
149
+ fn analyze_numeric_table_name ( ) {
168
150
run_sunny_day_test (
169
151
"ANALYZE main.'123';" ,
170
152
Statement :: Analyze ( AnalyzeStatement {
@@ -175,7 +157,7 @@ mod analyze_statements_tests {
175
157
}
176
158
177
159
#[ test]
178
- fn test_analyze_with_escaped_quotes_in_schema_name ( ) {
160
+ fn analyze_with_escaped_quotes_in_schema_name ( ) {
179
161
run_sunny_day_test (
180
162
"ANALYZE 'main''db';" ,
181
163
Statement :: Analyze ( AnalyzeStatement {
@@ -186,7 +168,7 @@ mod analyze_statements_tests {
186
168
}
187
169
188
170
#[ test]
189
- fn test_analyze_with_escaped_quotes_in_table_name ( ) {
171
+ fn analyze_with_escaped_quotes_in_table_name ( ) {
190
172
run_sunny_day_test (
191
173
"ANALYZE main.'table''name';" ,
192
174
Statement :: Analyze ( AnalyzeStatement {
@@ -197,7 +179,7 @@ mod analyze_statements_tests {
197
179
}
198
180
199
181
#[ test]
200
- fn test_analyze_with_backticks_schema_name ( ) {
182
+ fn analyze_with_backticks_schema_name ( ) {
201
183
run_sunny_day_test (
202
184
"ANALYZE `main`;" ,
203
185
Statement :: Analyze ( AnalyzeStatement {
@@ -208,7 +190,7 @@ mod analyze_statements_tests {
208
190
}
209
191
210
192
#[ test]
211
- fn test_analyze_with_special_chars_in_table_name ( ) {
193
+ fn analyze_with_special_chars_in_table_name ( ) {
212
194
run_sunny_day_test (
213
195
"ANALYZE main.'[email protected]!';" ,
214
196
Statement :: Analyze ( AnalyzeStatement {
@@ -219,7 +201,7 @@ mod analyze_statements_tests {
219
201
}
220
202
221
203
#[ test]
222
- fn test_analyze_multiple_statements ( ) {
204
+ fn analyze_multiple_statements ( ) {
223
205
let sql = "ANALYZE; ANALYZE main.my_table;" ;
224
206
let mut parser = Parser :: from ( sql) ;
225
207
0 commit comments