mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-19 06:15:00 +00:00
Require that nested joins always have one join
The SQL specification prohibits constructions like SELECT * FROM a NATURAL JOIN (b) where b sits alone inside parentheses. Parentheses in a FROM entry always introduce either a derived table or a join.
This commit is contained in:
parent
8bee74277a
commit
4ee461bae4
3 changed files with 27 additions and 1 deletions
|
@ -1742,6 +1742,12 @@ fn parse_join_nesting() {
|
|||
from.joins,
|
||||
vec![join(nest!(nest!(nest!(table("b"), table("c")))))]
|
||||
);
|
||||
|
||||
let res = parse_sql_statements("SELECT * FROM (a NATURAL JOIN (b))");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected joined table, found: )".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1873,7 +1879,13 @@ fn parse_derived_tables() {
|
|||
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
|
||||
}],
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
||||
let res = parse_sql_statements("SELECT * FROM ((SELECT 1) AS t)");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected joined table, found: )".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue