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 {
36
36
private EXEC_TYPE execType = EXEC_TYPE .EXECUTE ;
37
37
private String name ;
38
38
private ExpressionList exprList ;
39
+ private boolean parenthesis = false ;
39
40
40
41
public String getName () {
41
42
return name ;
@@ -71,6 +72,14 @@ public void setExecType(EXEC_TYPE execType) {
71
72
this .execType = execType ;
72
73
}
73
74
75
+ public boolean isParenthesis () {
76
+ return parenthesis ;
77
+ }
78
+
79
+ public void setParenthesis (boolean parenthesis ) {
80
+ this .parenthesis = parenthesis ;
81
+ }
82
+
74
83
@ Override
75
84
public void accept (StatementVisitor statementVisitor ) {
76
85
statementVisitor .visit (this );
@@ -80,7 +89,7 @@ public void accept(StatementVisitor statementVisitor) {
80
89
public String toString () {
81
90
return execType .name () + " " + name
82
91
+ (exprList != null && exprList .getExpressions () != null ? " "
83
- + PlainSelect .getStringList (exprList .getExpressions (), true , false ) : "" );
92
+ + PlainSelect .getStringList (exprList .getExpressions (), true , parenthesis ) : "" );
84
93
}
85
94
86
95
public static enum EXEC_TYPE {
Original file line number Diff line number Diff line change @@ -52,16 +52,23 @@ public void setBuffer(StringBuilder buffer) {
52
52
53
53
public void deParse (Execute execute ) {
54
54
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
+ }
55
60
if (execute .getExprList () != null ) {
56
61
List <Expression > expressions = execute .getExprList ().getExpressions ();
57
62
for (int i = 0 ; i < expressions .size (); i ++) {
58
63
if (i > 0 ) {
59
- buffer .append ("," );
64
+ buffer .append (", " );
60
65
}
61
- buffer .append (" " );
62
66
expressions .get (i ).accept (expressionVisitor );
63
67
}
64
68
}
69
+ if (execute .isParenthesis ()) {
70
+ buffer .append (")" );
71
+ }
65
72
}
66
73
67
74
public ExpressionVisitor getExpressionVisitor () {
Original file line number Diff line number Diff line change @@ -2905,7 +2905,11 @@ Execute Execute(): {
2905
2905
2906
2906
funcName=RelObjectNameList() { execute.setName(funcName); }
2907
2907
2908
- [ expressionList=SimpleExpressionList() ]
2908
+ (
2909
+ LOOKAHEAD(3) expressionList=SimpleExpressionList()
2910
+ |
2911
+ ("(" expressionList=SimpleExpressionList() ")" { execute.setParenthesis(true); })
2912
+ )?
2909
2913
2910
2914
{
2911
2915
execute.setExprList(expressionList);
Original file line number Diff line number Diff line change @@ -75,4 +75,9 @@ public void testAcceptCall() throws JSQLParserException {
75
75
public void testCallWithMultiname () throws JSQLParserException {
76
76
assertSqlCanBeParsedAndDeparsed ("CALL BAR.FOO" );
77
77
}
78
+
79
+ @ Test
80
+ public void testAcceptCallWithParenthesis () throws JSQLParserException {
81
+ assertSqlCanBeParsedAndDeparsed ("CALL myproc ('a', 2, 'b')" );
82
+ }
78
83
}
You can’t perform that action at this time.
0 commit comments