File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,19 @@ impl TestedDialects {
6969 // Parser::parse_sql(&**self.dialects.first().unwrap(), sql)
7070 }
7171
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.
7577 pub fn one_statement_parses_to ( & self , sql : & str , canonical : & str ) -> Statement {
7678 let mut statements = self . parse_sql_statements ( & sql) . unwrap ( ) ;
7779 assert_eq ! ( statements. len( ) , 1 ) ;
7880
81+ if !canonical. is_empty ( ) && sql != canonical {
82+ assert_eq ! ( self . parse_sql_statements( & canonical) . unwrap( ) , statements) ;
83+ }
84+
7985 let only_statement = statements. pop ( ) . unwrap ( ) ;
8086 if !canonical. is_empty ( ) {
8187 assert_eq ! ( canonical, only_statement. to_string( ) )
You can’t perform that action at this time.
0 commit comments