Skip to content

Commit e8ff9fb

Browse files
feat: syntax sugar for table functions
Signed-off-by: Andreas Reichel <[email protected]> Signed-off-by: manticore-projects <[email protected]>
1 parent b0b0f4d commit e8ff9fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/java/net/sf/jsqlparser/expression/Function.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.sf.jsqlparser.statement.select.OrderByElement;
1818

1919
import java.util.Arrays;
20+
import java.util.Collections;
2021
import java.util.List;
2122

2223
/**
@@ -44,7 +45,7 @@ public class Function extends ASTNodeAccessImpl implements Expression {
4445
public Function() {}
4546

4647
public Function(String name, Expression... parameters) {
47-
this.nameparts = Arrays.asList(name);
48+
this.nameparts = Collections.singletonList(name);
4849
this.parameters = new ExpressionList<>(parameters);
4950
}
5051

src/main/java/net/sf/jsqlparser/statement/select/TableFunction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package net.sf.jsqlparser.statement.select;
1111

1212
import net.sf.jsqlparser.expression.Alias;
13+
import net.sf.jsqlparser.expression.Expression;
1314
import net.sf.jsqlparser.expression.Function;
1415

1516
@SuppressWarnings({"PMD.UncommentedEmptyMethodBody"})
@@ -29,6 +30,15 @@ public TableFunction(String prefix, Function function) {
2930
this.function = function;
3031
}
3132

33+
public TableFunction(String prefix, String name, Expression... parameters) {
34+
this.prefix = prefix;
35+
this.function = new Function(name, parameters);
36+
}
37+
38+
public TableFunction(String name, Expression... parameters) {
39+
this(null, name, parameters);
40+
}
41+
3242
public Function getFunction() {
3343
return function;
3444
}

0 commit comments

Comments
 (0)