mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 14:28:22 +00:00
Fix qualified wildcard stringifying
This commit is contained in:
parent
ef76baa7fd
commit
5b464e6b1a
2 changed files with 14 additions and 1 deletions
|
@ -111,7 +111,7 @@ impl ToString for ASTNode {
|
|||
match self {
|
||||
ASTNode::SQLIdentifier(s) => s.to_string(),
|
||||
ASTNode::SQLWildcard => "*".to_string(),
|
||||
ASTNode::SQLQualifiedWildcard(q) => q.join(".") + "*",
|
||||
ASTNode::SQLQualifiedWildcard(q) => q.join(".") + ".*",
|
||||
ASTNode::SQLCompoundIdentifier(s) => s.join("."),
|
||||
ASTNode::SQLIsNull(ast) => format!("{} IS NULL", ast.as_ref().to_string()),
|
||||
ASTNode::SQLIsNotNull(ast) => format!("{} IS NOT NULL", ast.as_ref().to_string()),
|
||||
|
|
|
@ -20,3 +20,16 @@ fn parse_simple_select() {
|
|||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn roundtrip_qualified_wildcard() {
|
||||
let sql = String::from("SELECT COUNT(Employee.*) FROM northwind.Order JOIN northwind.Employee ON Order.employee = Employee.id");
|
||||
let ast = Parser::parse_sql(&AnsiSqlDialect {}, sql.clone()).unwrap();
|
||||
assert_eq!(1, ast.len());
|
||||
match ast.first().unwrap() {
|
||||
SQLStatement::SQLSelect(ref query) => {
|
||||
assert_eq!(sql, query.to_string());
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue