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:
Nikhil Benesch 2019-06-09 15:08:17 -04:00
parent 8bee74277a
commit 4ee461bae4
No known key found for this signature in database
GPG key ID: FCF98542083C5A69
3 changed files with 27 additions and 1 deletions

View file

@ -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]