File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public class PlainSelect extends ASTNodeAccessImpl implements SelectBody {
3535 private Fetch fetch ;
3636 private OptimizeFor optimizeFor ;
3737 private Skip skip ;
38+ private boolean mySqlHintStraightJoin ;
3839 private First first ;
3940 private Top top ;
4041 private OracleHierarchicalExpression oracleHierarchical = null ;
@@ -170,6 +171,14 @@ public void setSkip(Skip skip) {
170171 this .skip = skip ;
171172 }
172173
174+ public boolean getMySqlHintStraightJoin () {
175+ return this .mySqlHintStraightJoin ;
176+ }
177+
178+ public void setMySqlHintStraightJoin (boolean mySqlHintStraightJoin ) {
179+ this .mySqlHintStraightJoin = mySqlHintStraightJoin ;
180+ }
181+
173182 public First getFirst () {
174183 return first ;
175184 }
@@ -297,6 +306,10 @@ public String toString() {
297306 }
298307 sql .append ("SELECT " );
299308
309+ if (this .mySqlHintStraightJoin ) {
310+ sql .append ("STRAIGHT_JOIN " );
311+ }
312+
300313 if (oracleHint != null ) {
301314 sql .append (oracleHint ).append (" " );
302315 }
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public void visit(PlainSelect plainSelect) {
3636 }
3737 buffer .append ("SELECT " );
3838
39+ if (plainSelect .getMySqlHintStraightJoin ()) {
40+ buffer .append ("STRAIGHT_JOIN " );
41+ }
42+
3943 OracleHint hint = plainSelect .getOracleHint ();
4044 if (hint != null ) {
4145 buffer .append (hint ).append (" " );
Original file line number Diff line number Diff line change @@ -1281,6 +1281,8 @@ PlainSelect PlainSelect() #PlainSelect:
12811281{
12821282 <K_SELECT>
12831283
1284+ [ <K_STRAIGHT> { plainSelect.setMySqlHintStraightJoin(true); } ]
1285+
12841286 { plainSelect.setOracleHint(getOracleHint()); }
12851287
12861288 [skip = Skip() { plainSelect.setSkip(skip); } ]
Original file line number Diff line number Diff line change @@ -1637,11 +1637,17 @@ public void testCastTypeProblem2() throws JSQLParserException {
16371637 }
16381638
16391639 @ Test
1640- public void testStraightJoin () throws JSQLParserException {
1640+ public void testMySQLHintStraightJoin () throws JSQLParserException {
16411641 String stmt = "SELECT col FROM tbl STRAIGHT_JOIN tbl2 ON tbl.id = tbl2.id" ;
16421642 assertSqlCanBeParsedAndDeparsed (stmt );
16431643 }
16441644
1645+ @ Test
1646+ public void testStraightJoinInSelect () throws JSQLParserException {
1647+ String stmt = "SELECT STRAIGHT_JOIN col, col2 FROM tbl INNER JOIN tbl2 ON tbl.id = tbl2.id" ;
1648+ assertSqlCanBeParsedAndDeparsed (stmt );
1649+ }
1650+
16451651 @ Test
16461652 public void testCastTypeProblem3 () throws JSQLParserException {
16471653 String stmt = "SELECT col1::varchar (256) FROM tabelle1" ;
You can’t perform that action at this time.
0 commit comments