This commit is contained in:
James Sadler 2025-06-26 20:56:07 +10:00 committed by GitHub
commit cfe6dcaaff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View file

@ -3471,7 +3471,7 @@ impl<'a> Parser<'a> {
right
};
if !matches!(
if !dialect_of!(self is PostgreSqlDialect) && !matches!(
op,
BinaryOperator::Gt
| BinaryOperator::Lt

View file

@ -6151,6 +6151,36 @@ fn parse_bitstring_literal() {
);
}
#[test]
fn parse_arbitrary_operator_with_any_and_all() {
// The following statement is semantically non-sensical on vanilla postgres but it should *parse* in order to
// support situations where PG operators have been overloaded.
let select = pg().verified_only_select("SELECT 123 % ANY(ARRAY[1, 2, 3])");
assert!(
matches!(
select.projection[0],
SelectItem::UnnamedExpr(Expr::AnyOp {
left: _,
compare_op: BinaryOperator::Modulo,
right: _,
is_some: false
})
)
);
let select = pg().verified_only_select("SELECT 123 % ALL(ARRAY[1, 2, 3])");
assert!(
matches!(
select.projection[0],
SelectItem::UnnamedExpr(Expr::AllOp {
left: _,
compare_op: BinaryOperator::Modulo,
right: _,
})
)
);
}
#[test]
fn parse_varbit_datatype() {
match pg_and_generic().verified_stmt("CREATE TABLE foo (x VARBIT, y VARBIT(42))") {