|
21 | 21 | use pretty_assertions::assert_eq; |
22 | 22 |
|
23 | 23 | use sqlparser::{ |
24 | | - ast::{BinaryOperator, Expr, Ident, QuoteDelimitedString, Value, ValueWithSpan}, |
25 | | - dialect::OracleDialect, |
26 | | - tokenizer::Span, |
| 24 | + ast::{BinaryOperator, Expr, Ident, QuoteDelimitedString, Value, ValueWithSpan}, dialect::OracleDialect, parser::ParserError, tokenizer::Span |
27 | 25 | }; |
28 | 26 | use test_utils::{expr_from_projection, number, TestedDialects}; |
29 | 27 |
|
@@ -184,6 +182,27 @@ fn parse_quote_delimited_string() { |
184 | 182 | ); |
185 | 183 | } |
186 | 184 |
|
| 185 | +#[test] |
| 186 | +fn parse_invalid_quote_delimited_strings() { |
| 187 | + // ~ invalid quote delimiter |
| 188 | + for q in [' ', '\t', '\r', '\n'] { |
| 189 | + assert_eq!( |
| 190 | + oracle().parse_sql_statements(&format!("SELECT Q'{q}abc{q}' FROM dual")), |
| 191 | + Err(ParserError::TokenizerError("Invalid space, tab, newline, or EOF after 'Q'' at Line: 1, Column: 10".into())), |
| 192 | + "with quote char {q:?}"); |
| 193 | + } |
| 194 | + // ~ invalid eof after quote |
| 195 | + assert_eq!( |
| 196 | + oracle().parse_sql_statements("SELECT Q'"), |
| 197 | + Err(ParserError::TokenizerError("Invalid space, tab, newline, or EOF after 'Q'' at Line: 1, Column: 10".into())), |
| 198 | + "with EOF quote char"); |
| 199 | + // ~ unterminated string |
| 200 | + assert_eq!( |
| 201 | + oracle().parse_sql_statements("SELECT Q'|asdfa...."), |
| 202 | + Err(ParserError::TokenizerError("Unterminated string literal at Line: 1, Column: 9".into())), |
| 203 | + "with EOF quote char"); |
| 204 | +} |
| 205 | + |
187 | 206 | #[test] |
188 | 207 | fn parse_quote_delimited_string_lowercase() { |
189 | 208 | let sql = "select q'!a'b'c!d!' from dual"; |
|
0 commit comments