File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,19 @@ impl TestedDialects {
69
69
// Parser::parse_sql(&**self.dialects.first().unwrap(), sql)
70
70
}
71
71
72
- /// Ensures that `sql` parses as a single statement, optionally checking
73
- /// that converting AST back to string equals to `canonical` (unless an
74
- /// empty canonical string is provided).
72
+ /// Ensures that `sql` parses as a single statement and returns it.
73
+ /// If non-empty `canonical` SQL representation is provided,
74
+ /// additionally asserts that parsing `sql` results in the same parse
75
+ /// tree as parsing `canonical`, and that serializing it back to string
76
+ /// results in the `canonical` representation.
75
77
pub fn one_statement_parses_to ( & self , sql : & str , canonical : & str ) -> Statement {
76
78
let mut statements = self . parse_sql_statements ( & sql) . unwrap ( ) ;
77
79
assert_eq ! ( statements. len( ) , 1 ) ;
78
80
81
+ if !canonical. is_empty ( ) && sql != canonical {
82
+ assert_eq ! ( self . parse_sql_statements( & canonical) . unwrap( ) , statements) ;
83
+ }
84
+
79
85
let only_statement = statements. pop ( ) . unwrap ( ) ;
80
86
if !canonical. is_empty ( ) {
81
87
assert_eq ! ( canonical, only_statement. to_string( ) )
You can’t perform that action at this time.
0 commit comments