|
9 | 9 | */ |
10 | 10 | package net.sf.jsqlparser.statement.select; |
11 | 11 |
|
12 | | -import net.sf.jsqlparser.expression.Alias; |
13 | | -import net.sf.jsqlparser.expression.Expression; |
14 | | -import net.sf.jsqlparser.expression.OracleHierarchicalExpression; |
15 | | -import net.sf.jsqlparser.expression.OracleHint; |
16 | | -import net.sf.jsqlparser.expression.PreferringClause; |
17 | | -import net.sf.jsqlparser.expression.WindowDefinition; |
18 | | -import net.sf.jsqlparser.schema.Table; |
| 12 | +import static java.util.stream.Collectors.joining; |
19 | 13 |
|
20 | 14 | import java.util.ArrayList; |
21 | 15 | import java.util.Arrays; |
|
24 | 18 | import java.util.Iterator; |
25 | 19 | import java.util.List; |
26 | 20 | import java.util.Optional; |
27 | | - |
28 | | -import static java.util.stream.Collectors.joining; |
| 21 | +import net.sf.jsqlparser.expression.Alias; |
| 22 | +import net.sf.jsqlparser.expression.Expression; |
| 23 | +import net.sf.jsqlparser.expression.OracleHierarchicalExpression; |
| 24 | +import net.sf.jsqlparser.expression.OracleHint; |
| 25 | +import net.sf.jsqlparser.expression.PreferringClause; |
| 26 | +import net.sf.jsqlparser.expression.WindowDefinition; |
| 27 | +import net.sf.jsqlparser.schema.Table; |
| 28 | +import net.sf.jsqlparser.statement.update.UpdateSet; |
29 | 29 |
|
30 | 30 | @SuppressWarnings({"PMD.CyclomaticComplexity"}) |
31 | 31 | public class PlainSelect extends Select { |
@@ -65,6 +65,7 @@ public class PlainSelect extends Select { |
65 | 65 | private boolean isUsingOnly = false; |
66 | 66 | private boolean useWithNoLog = false; |
67 | 67 | private Table intoTempTable = null; |
| 68 | + private List<UpdateSet> settings = null; |
68 | 69 |
|
69 | 70 | public PlainSelect() {} |
70 | 71 |
|
@@ -323,6 +324,19 @@ public PlainSelect withIntoTempTable(Table intoTempTable) { |
323 | 324 | return this; |
324 | 325 | } |
325 | 326 |
|
| 327 | + public List<UpdateSet> getSettings() { |
| 328 | + return settings; |
| 329 | + } |
| 330 | + |
| 331 | + public void setSettings(List<UpdateSet> settings) { |
| 332 | + this.settings = settings; |
| 333 | + } |
| 334 | + |
| 335 | + public PlainSelect withSettings(List<UpdateSet> settings) { |
| 336 | + this.setSettings(settings); |
| 337 | + return this; |
| 338 | + } |
| 339 | + |
326 | 340 | @Override |
327 | 341 | public <T, S> T accept(SelectVisitor<T> selectVisitor, S context) { |
328 | 342 | return selectVisitor.visit(this, context); |
@@ -632,6 +646,11 @@ public String toString() { |
632 | 646 | StringBuilder builder = new StringBuilder(); |
633 | 647 | super.appendTo(builder); |
634 | 648 |
|
| 649 | + if (settings != null && !settings.isEmpty()) { |
| 650 | + builder.append(" SETTINGS "); |
| 651 | + UpdateSet.appendUpdateSetsTo(builder, settings); |
| 652 | + } |
| 653 | + |
635 | 654 | if (optimizeFor != null) { |
636 | 655 | builder.append(optimizeFor); |
637 | 656 | } |
@@ -779,6 +798,18 @@ public PlainSelect addJoins(Collection<? extends Join> joins) { |
779 | 798 | return this.withJoins(collection); |
780 | 799 | } |
781 | 800 |
|
| 801 | + public PlainSelect addSettings(UpdateSet... settings) { |
| 802 | + List<UpdateSet> collection = Optional.ofNullable(getSettings()).orElseGet(ArrayList::new); |
| 803 | + Collections.addAll(collection, settings); |
| 804 | + return this.withSettings(collection); |
| 805 | + } |
| 806 | + |
| 807 | + public PlainSelect addSettings(Collection<? extends UpdateSet> settings) { |
| 808 | + List<UpdateSet> collection = Optional.ofNullable(getSettings()).orElseGet(ArrayList::new); |
| 809 | + collection.addAll(settings); |
| 810 | + return this.withSettings(collection); |
| 811 | + } |
| 812 | + |
782 | 813 | public <E extends FromItem> E getFromItem(Class<E> type) { |
783 | 814 | return type.cast(getFromItem()); |
784 | 815 | } |
|
0 commit comments