@@ -858,14 +858,7 @@ Select Select():
858858SelectBody SelectBody():
859859{ SelectBody selectBody = null; }
860860{
861- (
862- LOOKAHEAD(SetOperationList())
863- selectBody = SetOperationList()
864- |
865- selectBody = PlainSelect()
866- |
867- ( "(" selectBody = PlainSelect() { ((PlainSelect)selectBody).setUseBrackets(true); } ")" )
868- )
861+ selectBody = SetOperationList()
869862 { return selectBody; }
870863}
871864
@@ -943,7 +936,7 @@ PlainSelect PlainSelect():
943936 }
944937}
945938
946- SetOperationList SetOperationList():
939+ SelectBody SetOperationList():
947940{
948941 SetOperationList list = new SetOperationList();
949942 List<OrderByElement> orderByElements = null;
@@ -970,7 +963,7 @@ SetOperationList SetOperationList():
970963 )
971964
972965 (("(" select=SelectBody() ")" { bracket=true;} ) | select=PlainSelect() { bracket=false;} ) {selects.add(select);brackets.add(bracket);}
973- )+
966+ )*
974967 )
975968
976969 [orderByElements=OrderByElements() {list.setOrderByElements(orderByElements);} ]
@@ -980,8 +973,14 @@ SetOperationList SetOperationList():
980973 )
981974
982975 {
983- list.setBracketsOpsAndSelects(brackets,selects,operations);
984- return list;
976+ if (selects.size()==1 && selects.get(0) instanceof PlainSelect) {
977+ if (brackets.get(0))
978+ ((PlainSelect)selects.get(0)).setUseBrackets(true);
979+ return selects.get(0);
980+ } else {
981+ list.setBracketsOpsAndSelects(brackets,selects,operations);
982+ return list;
983+ }
985984 }
986985}
987986
0 commit comments