|
1 | 1 | use serde_json::json; |
2 | 2 |
|
3 | | -use sqlquack_syntax::{CallMode, Dialect, ParseOptions}; |
4 | | -use sqlquack_syntax_snowflake::parse_statements_with; |
| 3 | +use sqlquack_syntax::{CallMode, Dialect}; |
5 | 4 |
|
6 | 5 | use crate::helpers::{accepted, cast_targets, projection_at, statement_at, statements}; |
7 | 6 | use crate::test_types::{ |
8 | | - AcceptanceTestCase, CastTargetTestCase, ParseErrorTestCase, ParseMessageTestCase, |
9 | | - ProjectionTestCase, StatementTestCase, |
| 7 | + AcceptanceTestCase, CastTargetTestCase, ProjectionTestCase, StatementTestCase, |
10 | 8 | }; |
11 | 9 |
|
12 | 10 | #[test] |
@@ -1952,105 +1950,3 @@ fn given_a_keyword_lambda_parameter_when_parsing_duckdb_then_it_names_the_parame |
1952 | 1950 | ); |
1953 | 1951 | } |
1954 | 1952 | } |
1955 | | - |
1956 | | -#[test] |
1957 | | -fn given_group_or_order_by_after_an_operator_when_parsing_snowflake_then_the_error_is_at_the_clause( |
1958 | | -) { |
1959 | | - let test_cases = [ |
1960 | | - ParseErrorTestCase { |
1961 | | - description: "AND before GROUP BY on the next line fails at GROUP, not at BY", |
1962 | | - sql: "SELECT customer_id, SUM(total) AS revenue\nFROM orders\nWHERE status = 'shipped' AND\nGROUP BY customer_id", |
1963 | | - expected_error_at: Some("GROUP"), |
1964 | | - }, |
1965 | | - ParseErrorTestCase { |
1966 | | - description: "AND before ORDER BY on the same line fails at ORDER", |
1967 | | - sql: "SELECT order_id FROM orders WHERE total > 1 AND ORDER BY order_id", |
1968 | | - expected_error_at: Some("ORDER"), |
1969 | | - }, |
1970 | | - ParseErrorTestCase { |
1971 | | - description: "NOT before GROUP BY fails at GROUP", |
1972 | | - sql: "SELECT status FROM orders WHERE NOT\ngroup by status", |
1973 | | - expected_error_at: Some("group"), |
1974 | | - }, |
1975 | | - ParseErrorTestCase { |
1976 | | - description: "GROUP BY and ORDER BY after WHERE still parse", |
1977 | | - sql: "SELECT status FROM orders WHERE total > 1\nGROUP BY status\nORDER BY status", |
1978 | | - expected_error_at: None, |
1979 | | - }, |
1980 | | - ParseErrorTestCase { |
1981 | | - description: "a quoted GROUP column still parses", |
1982 | | - sql: "SELECT \"GROUP\" FROM orders ORDER BY 1", |
1983 | | - expected_error_at: None, |
1984 | | - }, |
1985 | | - ]; |
1986 | | - |
1987 | | - for test_case in test_cases { |
1988 | | - let error_at = parse_statements_with( |
1989 | | - test_case.sql, |
1990 | | - Dialect::Snowflake, |
1991 | | - &ParseOptions::default(), |
1992 | | - CallMode::Faithful, |
1993 | | - ) |
1994 | | - .err() |
1995 | | - .map(|error| { |
1996 | | - let start = error.start().unwrap_or_default(); |
1997 | | - let end = error.end().unwrap_or_default(); |
1998 | | - test_case.sql.get(start..end).unwrap_or_default().to_owned() |
1999 | | - }); |
2000 | | - assert_eq!( |
2001 | | - error_at.as_deref(), |
2002 | | - test_case.expected_error_at, |
2003 | | - "{}", |
2004 | | - test_case.description |
2005 | | - ); |
2006 | | - } |
2007 | | -} |
2008 | | - |
2009 | | -#[test] |
2010 | | -fn given_a_statement_ending_where_an_expression_belongs_when_parsing_snowflake_then_the_error_names_what_is_missing( |
2011 | | -) { |
2012 | | - let test_cases = [ |
2013 | | - ParseMessageTestCase { |
2014 | | - description: "an empty WHERE asks for a condition", |
2015 | | - sql: "SELECT * FROM orders WHERE", |
2016 | | - expected_message: "Expected a condition after WHERE", |
2017 | | - }, |
2018 | | - ParseMessageTestCase { |
2019 | | - description: "an empty WHERE before a semicolon asks for a condition", |
2020 | | - sql: "SELECT * FROM orders WHERE ;", |
2021 | | - expected_message: "Expected a condition after WHERE", |
2022 | | - }, |
2023 | | - ParseMessageTestCase { |
2024 | | - description: "an empty HAVING asks for a condition", |
2025 | | - sql: "SELECT status FROM orders GROUP BY status HAVING", |
2026 | | - expected_message: "Expected a condition after HAVING", |
2027 | | - }, |
2028 | | - ParseMessageTestCase { |
2029 | | - description: "a join's empty ON asks for a condition", |
2030 | | - sql: "SELECT 1 FROM orders o JOIN customers c ON", |
2031 | | - expected_message: "Expected a condition after ON", |
2032 | | - }, |
2033 | | - ParseMessageTestCase { |
2034 | | - description: "a comparison with no right side asks for an expression", |
2035 | | - sql: "SELECT 1 FROM orders WHERE total >", |
2036 | | - expected_message: "Expected an expression after >", |
2037 | | - }, |
2038 | | - ]; |
2039 | | - |
2040 | | - for test_case in test_cases { |
2041 | | - let message = parse_statements_with( |
2042 | | - test_case.sql, |
2043 | | - Dialect::Snowflake, |
2044 | | - &ParseOptions::default(), |
2045 | | - CallMode::Faithful, |
2046 | | - ) |
2047 | | - .err() |
2048 | | - .map(|error| error.to_string()) |
2049 | | - .unwrap_or_default(); |
2050 | | - assert!( |
2051 | | - message.contains(test_case.expected_message), |
2052 | | - "{}: {message}", |
2053 | | - test_case.description |
2054 | | - ); |
2055 | | - } |
2056 | | -} |
0 commit comments