Ensures that `sql` parses as a single [Statement] If `canonical` is non empty,this function additionally asserts that: 1. parsing `sql` results in the same [`Statement`] as parsing `canonical`. 2. re-serializing the result of parsing `sql` produces the same `canonical` sql string
(sql: &str, canonical: &str)
| 2005 | /// 2. re-serializing the result of parsing `sql` produces the same |
| 2006 | /// `canonical` sql string |
| 2007 | fn one_statement_parses_to(sql: &str, canonical: &str) -> Statement { |
| 2008 | let mut statements = DFParser::parse_sql(sql).unwrap(); |
| 2009 | assert_eq!(statements.len(), 1); |
| 2010 | |
| 2011 | if sql != canonical { |
| 2012 | assert_eq!(DFParser::parse_sql(canonical).unwrap(), statements); |
| 2013 | } |
| 2014 | |
| 2015 | let only_statement = statements.pop_front().unwrap(); |
| 2016 | assert_eq!( |
| 2017 | canonical.to_uppercase(), |
| 2018 | only_statement.to_string().to_uppercase() |
| 2019 | ); |
| 2020 | only_statement |
| 2021 | } |
| 2022 | |
| 2023 | /// Ensures that `sql` parses as a single [Statement], and that |
| 2024 | /// re-serializing the parse result produces the same `sql` |
no test coverage detected
searching dependent graphs…