Skip to content

Commit

Permalink
feat: syntax sugar for table functions
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Reichel <[email protected]>
Signed-off-by: manticore-projects <[email protected]>
  • Loading branch information
manticore-projects committed Dec 8, 2024
1 parent b0b0f4d commit e8ff9fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jsqlparser/expression/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.sf.jsqlparser.statement.select.OrderByElement;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -44,7 +45,7 @@ public class Function extends ASTNodeAccessImpl implements Expression {
public Function() {}

public Function(String name, Expression... parameters) {
this.nameparts = Arrays.asList(name);
this.nameparts = Collections.singletonList(name);
this.parameters = new ExpressionList<>(parameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package net.sf.jsqlparser.statement.select;

import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.Function;

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

public TableFunction(String prefix, String name, Expression... parameters) {
this.prefix = prefix;
this.function = new Function(name, parameters);
}

public TableFunction(String name, Expression... parameters) {
this(null, name, parameters);
}

public Function getFunction() {
return function;
}
Expand Down

0 comments on commit e8ff9fb

Please sign in to comment.