@@ -7131,12 +7131,45 @@ fn parse_cross_join() {
7131
7131
Join {
7132
7132
relation: table_from_name(ObjectName::from(vec![Ident::new("t2")])),
7133
7133
global: false,
7134
- join_operator: JoinOperator::CrossJoin,
7134
+ join_operator: JoinOperator::CrossJoin(JoinConstraint::None) ,
7135
7135
},
7136
7136
only(only(select.from).joins),
7137
7137
);
7138
7138
}
7139
7139
7140
+ #[test]
7141
+ fn parse_cross_join_constraint() {
7142
+ fn join_with_constraint(constraint: JoinConstraint) -> Join {
7143
+ Join {
7144
+ relation: table_from_name(ObjectName::from(vec![Ident::new("t2")])),
7145
+ global: false,
7146
+ join_operator: JoinOperator::CrossJoin(constraint),
7147
+ }
7148
+ }
7149
+
7150
+ fn test_constraint(sql: &str, constraint: JoinConstraint) {
7151
+ let dialect = all_dialects_where(|d| d.supports_cross_join_constraint());
7152
+ let select = dialect.verified_only_select(sql);
7153
+ assert_eq!(
7154
+ join_with_constraint(constraint),
7155
+ only(only(select.from).joins),
7156
+ );
7157
+ }
7158
+
7159
+ test_constraint(
7160
+ "SELECT * FROM t1 CROSS JOIN t2 ON a = b",
7161
+ JoinConstraint::On(Expr::BinaryOp {
7162
+ left: Box::new(Expr::Identifier(Ident::new("a"))),
7163
+ op: BinaryOperator::Eq,
7164
+ right: Box::new(Expr::Identifier(Ident::new("b"))),
7165
+ }),
7166
+ );
7167
+ test_constraint(
7168
+ "SELECT * FROM t1 CROSS JOIN t2 USING(a)",
7169
+ JoinConstraint::Using(vec![ObjectName::from(vec![Ident::new("a")])]),
7170
+ );
7171
+ }
7172
+
7140
7173
#[test]
7141
7174
fn parse_joins_on() {
7142
7175
fn join_with_constraint(
0 commit comments