Add logical xor (#357)

This commit is contained in:
John 2021-09-18 19:39:35 +09:00 committed by GitHub
parent a8901becc3
commit 014b82f03d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 0 deletions

View file

@ -815,6 +815,44 @@ fn parse_bitwise_ops() {
}
}
#[test]
fn parse_logical_xor() {
let sql = "SELECT true XOR true, false XOR false, true XOR false, false XOR true";
let select = verified_only_select(sql);
assert_eq!(
SelectItem::UnnamedExpr(Expr::BinaryOp {
left: Box::new(Expr::Value(Value::Boolean(true))),
op: BinaryOperator::Xor,
right: Box::new(Expr::Value(Value::Boolean(true))),
}),
select.projection[0]
);
assert_eq!(
SelectItem::UnnamedExpr(Expr::BinaryOp {
left: Box::new(Expr::Value(Value::Boolean(false))),
op: BinaryOperator::Xor,
right: Box::new(Expr::Value(Value::Boolean(false))),
}),
select.projection[1]
);
assert_eq!(
SelectItem::UnnamedExpr(Expr::BinaryOp {
left: Box::new(Expr::Value(Value::Boolean(true))),
op: BinaryOperator::Xor,
right: Box::new(Expr::Value(Value::Boolean(false))),
}),
select.projection[2]
);
assert_eq!(
SelectItem::UnnamedExpr(Expr::BinaryOp {
left: Box::new(Expr::Value(Value::Boolean(false))),
op: BinaryOperator::Xor,
right: Box::new(Expr::Value(Value::Boolean(true))),
}),
select.projection[3]
);
}
#[test]
fn parse_between() {
fn chk(negated: bool) {