Skip to content

Commit 3b83b5f

Browse files
committed
utilize typed string instead of cast
1 parent 0088796 commit 3b83b5f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/parser.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,15 @@ impl Parser {
194194
// expression that should parse as the column name "date".
195195
if let Some(parsed) = self.maybe_parse(|parser| match parser.parse_data_type()? {
196196
DataType::Interval => parser.parse_literal_interval(),
197-
data_type => Ok(Expr::Cast {
198-
expr: Box::new(Expr::Value(Value::SingleQuotedString(
199-
parser.parse_literal_string()?,
200-
))),
197+
// Single-quoted strings are parsed as custom data types, however this not desirable
198+
// when we are handling input like `"NOT 'a' NOT LIKE 'b'"` because this will produce a
199+
// TypedString instead of a SingleQuotedString. Further, this leads to issues where the
200+
// same input will yield a BinaryOperator instead of the correct UnaryOperator. Here we
201+
// handle that specific case by returning an error.
202+
DataType::Custom(..) => Err(ParserError::ParserError("".to_string())),
203+
data_type => Ok(Expr::TypedString {
201204
data_type,
205+
value: parser.parse_literal_string()?,
202206
}),
203207
}) {
204208
return Ok(parsed);

0 commit comments

Comments
 (0)