File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,8 @@ impl TestedDialects {
151
151
///
152
152
/// 2. re-serializing the result of parsing `sql` produces the same
153
153
/// `canonical` sql string
154
+ ///
155
+ /// For multiple statements, use [`statements_parse_to`].
154
156
pub fn one_statement_parses_to ( & self , sql : & str , canonical : & str ) -> Statement {
155
157
let mut statements = self . parse_sql_statements ( sql) . expect ( sql) ;
156
158
assert_eq ! ( statements. len( ) , 1 ) ;
@@ -166,6 +168,30 @@ impl TestedDialects {
166
168
only_statement
167
169
}
168
170
171
+ /// The same as [`one_statement_parses_to`] but it works for a multiple statements
172
+ pub fn statements_parse_to (
173
+ & self ,
174
+ sql : & str ,
175
+ statement_count : usize ,
176
+ canonical : & str ,
177
+ ) -> Vec < Statement > {
178
+ let statements = self . parse_sql_statements ( sql) . expect ( sql) ;
179
+ assert_eq ! ( statements. len( ) , statement_count) ;
180
+ if !canonical. is_empty ( ) && sql != canonical {
181
+ assert_eq ! ( self . parse_sql_statements( canonical) . unwrap( ) , statements) ;
182
+ } else {
183
+ assert_eq ! (
184
+ sql,
185
+ statements
186
+ . iter( )
187
+ . map( |s| s. to_string( ) )
188
+ . collect:: <Vec <_>>( )
189
+ . join( "; " )
190
+ ) ;
191
+ }
192
+ statements
193
+ }
194
+
169
195
/// Ensures that `sql` parses as an [`Expr`], and that
170
196
/// re-serializing the parse result produces canonical
171
197
pub fn expr_parses_to ( & self , sql : & str , canonical : & str ) -> Expr {
You can’t perform that action at this time.
0 commit comments