-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: support mysql with rollup #1923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,21 +9,22 @@ | |
| */ | ||
| package net.sf.jsqlparser.statement.select; | ||
|
|
||
| import net.sf.jsqlparser.expression.Expression; | ||
| import net.sf.jsqlparser.expression.operators.relational.ExpressionList; | ||
| import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import net.sf.jsqlparser.expression.Expression; | ||
| import net.sf.jsqlparser.expression.operators.relational.ExpressionList; | ||
| import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; | ||
|
|
||
| public class GroupByElement implements Serializable { | ||
| private ExpressionList groupByExpressions = new ExpressionList(); | ||
| private List<ExpressionList> groupingSets = new ArrayList<>(); | ||
| // postgres rollup is an ExpressionList | ||
| private boolean mysqlWithRollup = false; | ||
|
|
||
| public boolean isUsingBrackets() { | ||
| return groupByExpressions.isUsingBrackets(); | ||
|
|
@@ -90,6 +91,10 @@ public String toString() { | |
| b.append(")"); | ||
| } | ||
|
|
||
| if (isMysqlWithRollup()) { | ||
| b.append(" WITH ROLLUP"); | ||
| } | ||
|
|
||
| return b.toString(); | ||
| } | ||
|
|
||
|
|
@@ -126,4 +131,17 @@ public GroupByElement addGroupingSets(Collection<? extends Object> groupingSets) | |
| collection.addAll(groupingSets); | ||
| return this.withGroupingSets(collection); | ||
| } | ||
|
|
||
| public boolean isMysqlWithRollup() { | ||
| return mysqlWithRollup; | ||
| } | ||
|
|
||
| public void setMysqlWithRollup(boolean mysqlWithRollup) { | ||
| this.mysqlWithRollup = mysqlWithRollup; | ||
| } | ||
|
|
||
| public GroupByElement withMysqlWithRollup(boolean mysqlWithRollup) { | ||
|
||
| this.setMysqlWithRollup(mysqlWithRollup); | ||
| return this; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.