Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,9 @@ impl fmt::Display for Join {
self.relation,
suffix(constraint)
),
JoinOperator::StraightJoin(constraint) => {
write!(f, " STRAIGHT_JOIN {}{}", self.relation, suffix(constraint))
}
}
}
}
Expand Down Expand Up @@ -2197,6 +2200,8 @@ pub enum JoinOperator {
match_condition: Expr,
constraint: JoinConstraint,
},
/// STRAIGHT_JOIN (non-standard)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we include a link to the mysql docs for reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, done!

StraightJoin(JoinConstraint),
}

#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
Expand Down
1 change: 1 addition & 0 deletions src/ast/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,7 @@ impl Spanned for JoinOperator {
} => match_condition.span().union(&constraint.span()),
JoinOperator::Anti(join_constraint) => join_constraint.span(),
JoinOperator::Semi(join_constraint) => join_constraint.span(),
JoinOperator::StraightJoin(join_constraint) => join_constraint.span(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ define_keywords!(
STORAGE_INTEGRATION,
STORAGE_SERIALIZATION_POLICY,
STORED,
STRAIGHT_JOIN,
STRICT,
STRING,
STRUCT,
Expand Down
4 changes: 4 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11826,6 +11826,10 @@ impl<'a> Parser<'a> {
Keyword::OUTER => {
return self.expected("LEFT, RIGHT, or FULL", self.peek_token());
}
Keyword::STRAIGHT_JOIN => {
let _ = self.next_token(); // consume STRAIGHT_JOIN
JoinOperator::StraightJoin
}
_ if natural => {
return self.expected("a join type after NATURAL", self.peek_token());
}
Expand Down
7 changes: 7 additions & 0 deletions tests/sqlparser_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3587,3 +3587,10 @@ fn test_variable_assignment_using_colon_equal() {
_ => panic!("Unexpected statement {stmt}"),
}
}

#[test]
fn parse_straight_join() {
mysql().verified_stmt(
"SELECT a.*, b.* FROM table_a AS a STRAIGHT_JOIN table_b AS b ON a.b_id = b.id",
);
}