File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed
main/java/net/sf/jsqlparser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,15 @@ public String toString() {
5757 if (limitNull ) {
5858 retVal += "NULL" ;
5959 } else {
60- if (null != offset ) {
61- retVal += offset + ", " ;
62- }
63- if (null != rowCount ) {
64- retVal += rowCount ;
60+ if (limitAll ) {
61+ retVal += "ALL" ;
62+ } else {
63+ if (null != offset ) {
64+ retVal += offset + ", " ;
65+ }
66+ if (null != rowCount ) {
67+ retVal += rowCount ;
68+ }
6569 }
6670 }
6771
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ public void deParse(Limit limit) {
2424 if (limit .isLimitNull ()) {
2525 buffer .append ("NULL" );
2626 } else {
27- if (null != limit .getOffset ()) {
28- buffer .append (limit .getOffset ()).append (", " );
29- }
27+ if (limit .isLimitAll ()) {
28+ buffer .append ("ALL" );
29+ } else {
30+ if (null != limit .getOffset ()) {
31+ buffer .append (limit .getOffset ()).append (", " );
32+ }
3033
31- if (null != limit .getRowCount ()) {
32- buffer .append (limit .getRowCount ());
34+ if (null != limit .getRowCount ()) {
35+ buffer .append (limit .getRowCount ());
36+ }
3337 }
3438 }
3539 }
Original file line number Diff line number Diff line change @@ -339,6 +339,18 @@ public void testLimit2() throws JSQLParserException {
339339 assertTrue (((PlainSelect ) select .getSelectBody ()).getLimit ().isLimitNull ());
340340 assertSqlCanBeParsedAndDeparsed (statement );
341341
342+ statement = "SELECT * FROM mytable WHERE mytable.col = 9 LIMIT ALL OFFSET 5" ;
343+ select = (Select ) parserManager .parse (new StringReader (statement ));
344+ offset = ((PlainSelect ) select .getSelectBody ()).getLimit ().getOffset ();
345+ rowCount = ((PlainSelect ) select .getSelectBody ()).getLimit ().getRowCount ();
346+
347+ assertNull (offset );
348+ assertNull (rowCount );
349+ assertEquals (5 , ((PlainSelect ) select .getSelectBody ()).getOffset ().getOffset ());
350+ assertTrue (((PlainSelect ) select .getSelectBody ()).getLimit ().isLimitAll ());
351+ assertFalse (((PlainSelect ) select .getSelectBody ()).getLimit ().isLimitNull ());
352+ assertSqlCanBeParsedAndDeparsed (statement );
353+
342354 statement = "SELECT * FROM mytable WHERE mytable.col = 9 LIMIT 0 OFFSET 3" ;
343355 select = (Select ) parserManager .parse (new StringReader (statement ));
344356 offset = ((PlainSelect ) select .getSelectBody ()).getLimit ().getOffset ();
You can’t perform that action at this time.
0 commit comments