mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 18:57:21 +00:00
Use assert_matches! instead of matching manually
To fix clippy warnings about assert!(true / false)
This commit is contained in:
parent
dee30aabe0
commit
08bbce8992
2 changed files with 16 additions and 22 deletions
|
@ -25,3 +25,4 @@ uuid = "0.7.1"
|
|||
|
||||
[dev-dependencies]
|
||||
simple_logger = "1.0.1"
|
||||
matches = "0.1"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use matches::assert_matches;
|
||||
|
||||
use sqlparser::dialect::*;
|
||||
use sqlparser::sqlast::*;
|
||||
use sqlparser::sqlparser::*;
|
||||
|
@ -227,23 +229,17 @@ fn parse_not_precedence() {
|
|||
use self::ASTNode::*;
|
||||
// NOT has higher precedence than OR/AND, so the following must parse as (NOT true) OR true
|
||||
let sql = "NOT true OR true";
|
||||
match verified_expr(sql) {
|
||||
SQLBinaryExpr {
|
||||
op: SQLOperator::Or,
|
||||
..
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
};
|
||||
assert_matches!(verified_expr(sql), SQLBinaryExpr {
|
||||
op: SQLOperator::Or,
|
||||
..
|
||||
});
|
||||
|
||||
// But NOT has lower precedence than comparison operators, so the following parses as NOT (a IS NULL)
|
||||
let sql = "NOT a IS NULL";
|
||||
match verified_expr(sql) {
|
||||
SQLUnary {
|
||||
operator: SQLOperator::Not,
|
||||
..
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
};
|
||||
assert_matches!(verified_expr(sql), SQLUnary {
|
||||
operator: SQLOperator::Not,
|
||||
..
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -950,14 +946,11 @@ fn parse_multiple_statements() {
|
|||
fn parse_scalar_subqueries() {
|
||||
use self::ASTNode::*;
|
||||
let sql = "(SELECT 1) + (SELECT 2)";
|
||||
match verified_expr(sql) {
|
||||
SQLBinaryExpr {
|
||||
op: SQLOperator::Plus, ..
|
||||
//left: box SQLSubquery { .. },
|
||||
//right: box SQLSubquery { .. },
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
};
|
||||
assert_matches!(verified_expr(sql), SQLBinaryExpr {
|
||||
op: SQLOperator::Plus, ..
|
||||
//left: box SQLSubquery { .. },
|
||||
//right: box SQLSubquery { .. },
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue