Skip to content

Commit 44bc7d9

Browse files
committed
Share statement configuration across a full select statement
This shares the configuration among all query expressions so that union queries will have the same configuration
1 parent ff4c34b commit 44bc7d9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/org/mybatis/dynamic/sql/select/QueryExpressionDSL.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class QueryExpressionDSL<R>
5050
private final List<BasicColumn> selectList;
5151
private QueryExpressionWhereBuilder whereBuilder;
5252
private GroupByModel groupByModel;
53-
private final StatementConfiguration statementConfiguration = new StatementConfiguration();
5453
private QueryExpressionHavingBuilder havingBuilder;
5554

5655
protected QueryExpressionDSL(FromGatherer<R> fromGatherer, TableExpression table) {
@@ -75,7 +74,7 @@ public QueryExpressionWhereBuilder where() {
7574

7675
@Override
7776
public QueryExpressionDSL<R> configureStatement(Consumer<StatementConfiguration> consumer) {
78-
consumer.accept(statementConfiguration);
77+
selectDSL.configureStatement(consumer);
7978
return this;
8079
}
8180

@@ -276,7 +275,7 @@ public FromGatherer<R> build() {
276275
public class QueryExpressionWhereBuilder extends AbstractWhereFinisher<QueryExpressionWhereBuilder>
277276
implements Buildable<R> {
278277
private QueryExpressionWhereBuilder() {
279-
super(statementConfiguration);
278+
super(selectDSL.statementConfiguration);
280279
}
281280

282281
public UnionBuilder union() {
@@ -394,7 +393,7 @@ public R build() {
394393

395394
@Override
396395
public JoinSpecificationFinisher configureStatement(Consumer<StatementConfiguration> consumer) {
397-
consumer.accept(statementConfiguration);
396+
selectDSL.configureStatement(consumer);
398397
return this;
399398
}
400399

src/main/java/org/mybatis/dynamic/sql/select/SelectDSL.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class SelectDSL<R> implements Buildable<R>, ConfigurableStatement<SelectD
5050
private Long limit;
5151
private Long offset;
5252
private Long fetchFirstRows;
53+
final StatementConfiguration statementConfiguration = new StatementConfiguration();
5354

5455
private SelectDSL(Function<SelectModel, R> adapterFunction) {
5556
this.adapterFunction = Objects.requireNonNull(adapterFunction);
@@ -124,7 +125,7 @@ public FetchFirstFinisher fetchFirst(long fetchFirstRows) {
124125

125126
@Override
126127
public SelectDSL<R> configureStatement(Consumer<StatementConfiguration> consumer) {
127-
queryExpressions.forEach(q -> q.configureStatement(consumer));
128+
consumer.accept(statementConfiguration);
128129
return this;
129130
}
130131

0 commit comments

Comments
 (0)