mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-12 06:52:02 +00:00
MySQL: Support CROSS JOIN
constraint (#2025)
Some checks failed
Rust / test (beta) (push) Has been cancelled
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Some checks failed
Rust / test (beta) (push) Has been cancelled
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
This commit is contained in:
parent
280f51889f
commit
e3fbfd91b2
6 changed files with 62 additions and 6 deletions
|
@ -7131,12 +7131,45 @@ fn parse_cross_join() {
|
|||
Join {
|
||||
relation: table_from_name(ObjectName::from(vec![Ident::new("t2")])),
|
||||
global: false,
|
||||
join_operator: JoinOperator::CrossJoin,
|
||||
join_operator: JoinOperator::CrossJoin(JoinConstraint::None),
|
||||
},
|
||||
only(only(select.from).joins),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_cross_join_constraint() {
|
||||
fn join_with_constraint(constraint: JoinConstraint) -> Join {
|
||||
Join {
|
||||
relation: table_from_name(ObjectName::from(vec![Ident::new("t2")])),
|
||||
global: false,
|
||||
join_operator: JoinOperator::CrossJoin(constraint),
|
||||
}
|
||||
}
|
||||
|
||||
fn test_constraint(sql: &str, constraint: JoinConstraint) {
|
||||
let dialect = all_dialects_where(|d| d.supports_cross_join_constraint());
|
||||
let select = dialect.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
join_with_constraint(constraint),
|
||||
only(only(select.from).joins),
|
||||
);
|
||||
}
|
||||
|
||||
test_constraint(
|
||||
"SELECT * FROM t1 CROSS JOIN t2 ON a = b",
|
||||
JoinConstraint::On(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("a"))),
|
||||
op: BinaryOperator::Eq,
|
||||
right: Box::new(Expr::Identifier(Ident::new("b"))),
|
||||
}),
|
||||
);
|
||||
test_constraint(
|
||||
"SELECT * FROM t1 CROSS JOIN t2 USING(a)",
|
||||
JoinConstraint::Using(vec![ObjectName::from(vec![Ident::new("a")])]),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_joins_on() {
|
||||
fn join_with_constraint(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue