mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Add LIKE operator
This commit is contained in:
parent
face97226b
commit
91aa985ed0
5 changed files with 27 additions and 3 deletions
|
@ -730,3 +730,23 @@ fn parser(sql: &str) -> Parser {
|
|||
debug!("tokens: {:#?}", tokens);
|
||||
Parser::new(tokens)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_like() {
|
||||
let sql = String::from("SELECT * FROM customers WHERE name LIKE '%a'");
|
||||
let ast = parse_sql(&sql);
|
||||
assert_eq!(sql, ast.to_string());
|
||||
match ast {
|
||||
ASTNode::SQLSelect { selection, .. } => {
|
||||
assert_eq!(
|
||||
ASTNode::SQLBinaryExpr {
|
||||
left: Box::new(ASTNode::SQLIdentifier("name".to_string())),
|
||||
op: SQLOperator::Like,
|
||||
right: Box::new(ASTNode::SQLValue(Value::SingleQuotedString("%a".to_string()))),
|
||||
},
|
||||
*selection.unwrap()
|
||||
);
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue