mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
feat: Support PostgreSQL exponentiation. (#813)
* Add Postgres exponent operator * Parse caret as BinaryOperator::PGExp in PostgreSQL * Update sqlparser_postgres.rs * update tests to support PGExp * cargo fmt * improve extensibility * cargo fmt * redundant code and documentation lionks
This commit is contained in:
parent
fbbf1a4e84
commit
1cf913e717
4 changed files with 32 additions and 10 deletions
|
@ -1228,16 +1228,27 @@ fn parse_string_agg() {
|
|||
);
|
||||
}
|
||||
|
||||
/// selects all dialects but PostgreSQL
|
||||
pub fn all_dialects_but_pg() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: all_dialects()
|
||||
.dialects
|
||||
.into_iter()
|
||||
.filter(|x| !x.is::<PostgreSqlDialect>())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_bitwise_ops() {
|
||||
let bitwise_ops = &[
|
||||
("^", BinaryOperator::BitwiseXor),
|
||||
("|", BinaryOperator::BitwiseOr),
|
||||
("&", BinaryOperator::BitwiseAnd),
|
||||
("^", BinaryOperator::BitwiseXor, all_dialects_but_pg()),
|
||||
("|", BinaryOperator::BitwiseOr, all_dialects()),
|
||||
("&", BinaryOperator::BitwiseAnd, all_dialects()),
|
||||
];
|
||||
|
||||
for (str_op, op) in bitwise_ops {
|
||||
let select = verified_only_select(&format!("SELECT a {} b", &str_op));
|
||||
for (str_op, op, dialects) in bitwise_ops {
|
||||
let select = dialects.verified_only_select(&format!("SELECT a {} b", &str_op));
|
||||
assert_eq!(
|
||||
SelectItem::UnnamedExpr(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("a"))),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue