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

This commit is contained in:
Sidney Cammeresi 2025-09-15 00:33:17 -07:00 committed by GitHub
parent 280f51889f
commit e3fbfd91b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 62 additions and 6 deletions

View file

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