LucaCappelletti94 commented on code in PR #3086:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/3086#discussion_r4757434123
##########
tests/sqlparser_oracle.rs:
##########
@@ -545,3 +545,53 @@ fn parse_non_reserved_keyword_table_names() {
oracle().verified_stmt("SELECT * FROM limit");
oracle().verified_stmt("SELECT * FROM t JOIN limit ON TRUE");
}
+
+#[test]
+fn parse_caret_not_equal() {
+ // `^=` is parsed as the standard not-equal operator
+ let expr = oracle().verified_expr("a <> b");
+ let select = oracle().verified_only_select_with_canonical(
+ "SELECT * FROM t WHERE a ^= b",
+ "SELECT * FROM t WHERE a <> b",
+ );
+ assert_eq!(select.selection, Some(expr));
+ assert!(matches!(
+ select.selection,
+ Some(Expr::BinaryOp {
+ op: BinaryOperator::NotEq,
+ ..
+ })
+ ));
+
+ // display normalizes `^=` to `<>`
+ oracle().one_statement_parses_to(
+ "SELECT id FROM t WHERE id^=1",
+ "SELECT id FROM t WHERE id <> 1",
+ );
+ oracle().one_statement_parses_to(
+ "SELECT 1 FROM dual WHERE (1,2) ^= ((1,3))",
+ "SELECT 1 FROM dual WHERE (1, 2) <> ((1, 3))",
+ );
+ oracle().one_statement_parses_to(
+ "SELECT CASE WHEN a ^= b THEN 1 END FROM t WHERE x ^= 1 AND y ^= 'z'",
+ "SELECT CASE WHEN a <> b THEN 1 END FROM t WHERE x <> 1 AND y <> 'z'",
+ );
+
+ // the caret and equals sign must be contiguous
+ assert_eq!(
+ oracle()
+ .parse_sql_statements("SELECT id FROM t WHERE id ^ = 1")
+ .unwrap_err()
+ .to_string(),
+ "sql parser error: Expected: an expression, found: ="
Review Comment:
Use typed errors instead of the `to_string`, likely you can also drop the
`unwrap_err`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]