Skip to content

Commit 552def1

Browse files
committed
fmt
1 parent 989f6dd commit 552def1

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

src/ast/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ impl fmt::Display for PipeOperator {
28612861
)?;
28622862
Self::fmt_optional_alias(f, alias)
28632863
}
2864-
PipeOperator::Join(join) => write!(f, "{}", join)
2864+
PipeOperator::Join(join) => write!(f, "{}", join),
28652865
}
28662866
}
28672867
}

src/parser/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11336,7 +11336,11 @@ impl<'a> Parser<'a> {
1133611336
let relation = self.parse_table_factor()?;
1133711337
let constraint = self.parse_join_constraint(false)?;
1133811338
if matches!(constraint, JoinConstraint::None) {
11339-
let join_type = if outer { "LEFT OUTER JOIN" } else { "LEFT JOIN" };
11339+
let join_type = if outer {
11340+
"LEFT OUTER JOIN"
11341+
} else {
11342+
"LEFT JOIN"
11343+
};
1134011344
return Err(ParserError::ParserError(format!(
1134111345
"{} in pipe syntax requires ON or USING clause",
1134211346
join_type
@@ -11359,7 +11363,11 @@ impl<'a> Parser<'a> {
1135911363
let relation = self.parse_table_factor()?;
1136011364
let constraint = self.parse_join_constraint(false)?;
1136111365
if matches!(constraint, JoinConstraint::None) {
11362-
let join_type = if outer { "RIGHT OUTER JOIN" } else { "RIGHT JOIN" };
11366+
let join_type = if outer {
11367+
"RIGHT OUTER JOIN"
11368+
} else {
11369+
"RIGHT JOIN"
11370+
};
1136311371
return Err(ParserError::ParserError(format!(
1136411372
"{} in pipe syntax requires ON or USING clause",
1136511373
join_type

tests/sqlparser_common.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15364,25 +15364,29 @@ fn parse_pipeline_operator() {
1536415364
// join pipe operator - INNER JOIN
1536515365
dialects.verified_stmt("SELECT * FROM users |> JOIN orders ON users.id = orders.user_id");
1536615366
dialects.verified_stmt("SELECT * FROM users |> INNER JOIN orders ON users.id = orders.user_id");
15367-
15367+
1536815368
// join pipe operator - LEFT JOIN
1536915369
dialects.verified_stmt("SELECT * FROM users |> LEFT JOIN orders ON users.id = orders.user_id");
15370-
dialects.verified_stmt("SELECT * FROM users |> LEFT OUTER JOIN orders ON users.id = orders.user_id");
15371-
15370+
dialects.verified_stmt(
15371+
"SELECT * FROM users |> LEFT OUTER JOIN orders ON users.id = orders.user_id",
15372+
);
15373+
1537215374
// join pipe operator - RIGHT JOIN
1537315375
dialects.verified_stmt("SELECT * FROM users |> RIGHT JOIN orders ON users.id = orders.user_id");
15374-
dialects.verified_stmt("SELECT * FROM users |> RIGHT OUTER JOIN orders ON users.id = orders.user_id");
15375-
15376+
dialects.verified_stmt(
15377+
"SELECT * FROM users |> RIGHT OUTER JOIN orders ON users.id = orders.user_id",
15378+
);
15379+
1537615380
// join pipe operator - FULL JOIN
1537715381
dialects.verified_stmt("SELECT * FROM users |> FULL JOIN orders ON users.id = orders.user_id");
1537815382
dialects.verified_query_with_canonical(
1537915383
"SELECT * FROM users |> FULL OUTER JOIN orders ON users.id = orders.user_id",
1538015384
"SELECT * FROM users |> FULL JOIN orders ON users.id = orders.user_id",
1538115385
);
15382-
15386+
1538315387
// join pipe operator - CROSS JOIN
1538415388
dialects.verified_stmt("SELECT * FROM users |> CROSS JOIN orders");
15385-
15389+
1538615390
// join pipe operator with USING
1538715391
dialects.verified_query_with_canonical(
1538815392
"SELECT * FROM users |> JOIN orders USING (user_id)",
@@ -15392,22 +15396,22 @@ fn parse_pipeline_operator() {
1539215396
"SELECT * FROM users |> LEFT JOIN orders USING (user_id, order_date)",
1539315397
"SELECT * FROM users |> LEFT JOIN orders USING(user_id, order_date)",
1539415398
);
15395-
15399+
1539615400
// join pipe operator with alias
1539715401
dialects.verified_query_with_canonical(
1539815402
"SELECT * FROM users |> JOIN orders o ON users.id = o.user_id",
1539915403
"SELECT * FROM users |> JOIN orders AS o ON users.id = o.user_id",
1540015404
);
1540115405
dialects.verified_stmt("SELECT * FROM users |> LEFT JOIN orders AS o ON users.id = o.user_id");
15402-
15406+
1540315407
// join pipe operator with complex ON condition
1540415408
dialects.verified_stmt("SELECT * FROM users |> JOIN orders ON users.id = orders.user_id AND orders.status = 'active'");
1540515409
dialects.verified_stmt("SELECT * FROM users |> LEFT JOIN orders ON users.id = orders.user_id AND orders.amount > 100");
15406-
15410+
1540715411
// multiple join pipe operators
1540815412
dialects.verified_stmt("SELECT * FROM users |> JOIN orders ON users.id = orders.user_id |> JOIN products ON orders.product_id = products.id");
1540915413
dialects.verified_stmt("SELECT * FROM users |> LEFT JOIN orders ON users.id = orders.user_id |> RIGHT JOIN products ON orders.product_id = products.id");
15410-
15414+
1541115415
// join pipe operator with other pipe operators
1541215416
dialects.verified_stmt("SELECT * FROM users |> JOIN orders ON users.id = orders.user_id |> WHERE orders.amount > 100");
1541315417
dialects.verified_stmt("SELECT * FROM users |> WHERE users.active = true |> LEFT JOIN orders ON users.id = orders.user_id");
@@ -15590,7 +15594,9 @@ fn parse_pipeline_operator_negative_tests() {
1559015594

1559115595
// Test that CROSS JOIN with ON condition fails
1559215596
assert!(dialects
15593-
.parse_sql_statements("SELECT * FROM users |> CROSS JOIN orders ON users.id = orders.user_id")
15597+
.parse_sql_statements(
15598+
"SELECT * FROM users |> CROSS JOIN orders ON users.id = orders.user_id"
15599+
)
1559415600
.is_err());
1559515601

1559615602
// Test that CROSS JOIN with USING condition fails

0 commit comments

Comments
 (0)