Skip to content

Commit

Permalink
fixes #1505
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Apr 9, 2022
1 parent f3facb7 commit 41c77ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,14 @@ SelectBody SetOperationList() #SetOperationList: {

{
if (selects.size()==1 && selects.get(0) instanceof PlainSelect && orderByElements==null) {
if (brackets.get(0))
((PlainSelect)selects.get(0)).setUseBrackets(true);
if (brackets.get(0)) {
if (limit==null && offset==null && fetch==null && withIsolation==null)
((PlainSelect)selects.get(0)).setUseBrackets(true);
else {
list.setBracketsOpsAndSelects(brackets,selects,operations);
return list; //brackets with outside limit, offset
}
}
return selects.get(0);
} else {
if (selects.size()>1 && selects.get(selects.size()-1) instanceof PlainSelect && !brackets.get(brackets.size() - 1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,9 @@ public void testInsertTableArrays4() throws JSQLParserException {
+ " ARRAY[['breakfast', 'consulting'], ['meeting', 'lunch']])",
true);
}

@Test
public void testKeywordDefaultIssue1470() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("INSERT INTO mytable (col1, col2, col3) VALUES (?, 'sadfsd', default)");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5059,12 +5059,12 @@ public void testWithIsolation() throws JSQLParserException {
}

@Test
public void testKeywordDefaultIssue1470() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("INSERT INTO mytable (col1, col2, col3) VALUES (?, 'sadfsd', default)");
public void testLoclTimezone1471() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT TO_CHAR(CAST(SYSDATE AS TIMESTAMP WITH LOCAL TIME ZONE), 'HH:MI:SS AM TZD') FROM DUAL");
}

@Test
public void testLoclTimezone1471() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT TO_CHAR(CAST(SYSDATE AS TIMESTAMP WITH LOCAL TIME ZONE), 'HH:MI:SS AM TZD') FROM DUAL");
public void testMissingLimitIssue1505() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("(SELECT * FROM mytable) LIMIT 1");
}
}

0 comments on commit 41c77ca

Please sign in to comment.