File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/execute Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ public class Execute implements Statement {
3636 private EXEC_TYPE execType = EXEC_TYPE .EXECUTE ;
3737 private String name ;
3838 private ExpressionList exprList ;
39+ private boolean parenthesis = false ;
3940
4041 public String getName () {
4142 return name ;
@@ -71,6 +72,14 @@ public void setExecType(EXEC_TYPE execType) {
7172 this .execType = execType ;
7273 }
7374
75+ public boolean isParenthesis () {
76+ return parenthesis ;
77+ }
78+
79+ public void setParenthesis (boolean parenthesis ) {
80+ this .parenthesis = parenthesis ;
81+ }
82+
7483 @ Override
7584 public void accept (StatementVisitor statementVisitor ) {
7685 statementVisitor .visit (this );
@@ -80,7 +89,7 @@ public void accept(StatementVisitor statementVisitor) {
8089 public String toString () {
8190 return execType .name () + " " + name
8291 + (exprList != null && exprList .getExpressions () != null ? " "
83- + PlainSelect .getStringList (exprList .getExpressions (), true , false ) : "" );
92+ + PlainSelect .getStringList (exprList .getExpressions (), true , parenthesis ) : "" );
8493 }
8594
8695 public static enum EXEC_TYPE {
Original file line number Diff line number Diff line change @@ -52,16 +52,23 @@ public void setBuffer(StringBuilder buffer) {
5252
5353 public void deParse (Execute execute ) {
5454 buffer .append (execute .getExecType ().name ()).append (" " ).append (execute .getName ());
55+ if (execute .isParenthesis ()) {
56+ buffer .append (" (" );
57+ } else if (execute .getExprList () != null ) {
58+ buffer .append (" " );
59+ }
5560 if (execute .getExprList () != null ) {
5661 List <Expression > expressions = execute .getExprList ().getExpressions ();
5762 for (int i = 0 ; i < expressions .size (); i ++) {
5863 if (i > 0 ) {
59- buffer .append ("," );
64+ buffer .append (", " );
6065 }
61- buffer .append (" " );
6266 expressions .get (i ).accept (expressionVisitor );
6367 }
6468 }
69+ if (execute .isParenthesis ()) {
70+ buffer .append (")" );
71+ }
6572 }
6673
6774 public ExpressionVisitor getExpressionVisitor () {
Original file line number Diff line number Diff line change @@ -2905,7 +2905,11 @@ Execute Execute(): {
29052905
29062906 funcName=RelObjectNameList() { execute.setName(funcName); }
29072907
2908- [ expressionList=SimpleExpressionList() ]
2908+ (
2909+ LOOKAHEAD(3) expressionList=SimpleExpressionList()
2910+ |
2911+ ("(" expressionList=SimpleExpressionList() ")" { execute.setParenthesis(true); })
2912+ )?
29092913
29102914 {
29112915 execute.setExprList(expressionList);
Original file line number Diff line number Diff line change @@ -75,4 +75,9 @@ public void testAcceptCall() throws JSQLParserException {
7575 public void testCallWithMultiname () throws JSQLParserException {
7676 assertSqlCanBeParsedAndDeparsed ("CALL BAR.FOO" );
7777 }
78+
79+ @ Test
80+ public void testAcceptCallWithParenthesis () throws JSQLParserException {
81+ assertSqlCanBeParsedAndDeparsed ("CALL myproc ('a', 2, 'b')" );
82+ }
7883}
You can’t perform that action at this time.
0 commit comments