Skip to content

Commit d0c081e

Browse files
authored
Fix issue apache#2353: Incorrect canonicalization of NATURAL JOIN (apache#2355)
1 parent 575ee26 commit d0c081e

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

src/parser/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15994,6 +15994,7 @@ impl<'a> Parser<'a> {
1599415994
if !self
1599515995
.dialect
1599615996
.supports_left_associative_joins_without_parens()
15997+
&& !natural
1599715998
&& self.peek_parens_less_nested_join()
1599815999
{
1599916000
let joins = self.parse_joins()?;

tests/sqlparser_common.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17443,8 +17443,7 @@ fn column_check_enforced() {
1744317443

1744417444
#[test]
1744517445
fn join_precedence() {
17446-
all_dialects_except(|d| !d.supports_left_associative_joins_without_parens())
17447-
.verified_query_with_canonical(
17446+
all_dialects().verified_query_with_canonical(
1744817447
"SELECT *
1744917448
FROM t1
1745017449
NATURAL JOIN t5
@@ -17453,15 +17452,6 @@ fn join_precedence() {
1745317452
// canonical string without parentheses
1745417453
"SELECT * FROM t1 NATURAL JOIN t5 INNER JOIN t0 ON (t0.v1 + t5.v0) > 0 WHERE t0.v1 = t1.v0",
1745517454
);
17456-
all_dialects_except(|d| d.supports_left_associative_joins_without_parens()).verified_query_with_canonical(
17457-
"SELECT *
17458-
FROM t1
17459-
NATURAL JOIN t5
17460-
INNER JOIN t0 ON (t0.v1 + t5.v0) > 0
17461-
WHERE t0.v1 = t1.v0",
17462-
// canonical string with parentheses
17463-
"SELECT * FROM t1 NATURAL JOIN (t5 INNER JOIN t0 ON (t0.v1 + t5.v0) > 0) WHERE t0.v1 = t1.v0",
17464-
);
1746517455
}
1746617456

1746717457
#[test]

0 commit comments

Comments
 (0)