Skip to content

Commit 9344e48

Browse files
committed
Support calling "where()" with no parameters
1 parent 2010c8f commit 9344e48

File tree

9 files changed

+670
-4
lines changed

9 files changed

+670
-4
lines changed

src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ static UpdateDSL<UpdateModel> update(SqlTable table) {
133133
return UpdateDSL.update(table);
134134
}
135135

136+
static WhereDSL where() {
137+
return WhereDSL.where();
138+
}
139+
136140
static <T> WhereDSL where(BindableColumn<T> column, VisitableCondition<T> condition) {
137141
return WhereDSL.where(column, condition);
138142
}

src/main/java/org/mybatis/dynamic/sql/delete/DeleteDSL.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,10 @@ private DeleteDSL(SqlTable table, Function<DeleteModel, R> adapterFunction) {
3535
this.adapterFunction = Objects.requireNonNull(adapterFunction);
3636
}
3737

38+
public DeleteWhereBuilder where() {
39+
return new DeleteWhereBuilder();
40+
}
41+
3842
public <T> DeleteWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
3943
return new DeleteWhereBuilder(column, condition);
4044
}
@@ -70,6 +74,10 @@ public static <T> DeleteDSL<MyBatis3DeleteModelAdapter<T>> deleteFromWithMapper(
7074

7175
public class DeleteWhereBuilder extends AbstractWhereDSL<DeleteWhereBuilder> {
7276

77+
private <T> DeleteWhereBuilder() {
78+
super();
79+
}
80+
7381
private <T> DeleteWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
7482
super(column, condition);
7583
}

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

+13
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public static <R> FromGatherer<R> selectDistinct(SelectDSL<R> selectDSL, BasicCo
8282
.build();
8383
}
8484

85+
public QueryExpressionWhereBuilder where() {
86+
return new QueryExpressionWhereBuilder();
87+
}
88+
8589
public <T> QueryExpressionWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
8690
return new QueryExpressionWhereBuilder(column, condition);
8791
}
@@ -261,6 +265,10 @@ public FromGatherer<R> build() {
261265

262266
public class QueryExpressionWhereBuilder extends AbstractWhereDSL<QueryExpressionWhereBuilder>
263267
implements Buildable<R> {
268+
private <T> QueryExpressionWhereBuilder() {
269+
buildDelegateMethod = this::internalBuild;
270+
}
271+
264272
private <T> QueryExpressionWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
265273
super(column, condition);
266274
buildDelegateMethod = this::internalBuild;
@@ -413,6 +421,11 @@ private R internalbuild() {
413421
return selectDSL.build();
414422
}
415423

424+
public QueryExpressionWhereBuilder where() {
425+
joinModel = buildJoinModel();
426+
return new QueryExpressionWhereBuilder();
427+
}
428+
416429
public <T> QueryExpressionWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
417430
joinModel = buildJoinModel();
418431
return new QueryExpressionWhereBuilder(column, condition);

src/main/java/org/mybatis/dynamic/sql/update/UpdateDSL.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,6 +54,10 @@ public <T> SetClauseFinisher<T> set(SqlColumn<T> column) {
5454
return new SetClauseFinisher<>(column);
5555
}
5656

57+
public UpdateWhereBuilder where() {
58+
return new UpdateWhereBuilder();
59+
}
60+
5761
public <T> UpdateWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
5862
return new UpdateWhereBuilder(column, condition);
5963
}
@@ -145,6 +149,10 @@ public UpdateDSL<R> equalToWhenPresent(Supplier<T> valueSupplier) {
145149

146150
public class UpdateWhereBuilder extends AbstractWhereDSL<UpdateWhereBuilder> {
147151

152+
public <T> UpdateWhereBuilder() {
153+
super();
154+
}
155+
148156
public <T> UpdateWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
149157
super(column, condition);
150158
}

src/main/java/org/mybatis/dynamic/sql/where/AbstractWhereDSL.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,10 @@
2626
public abstract class AbstractWhereDSL<T extends AbstractWhereDSL<T>> {
2727
private List<SqlCriterion<?>> criteria = new ArrayList<>();
2828

29+
protected <S> AbstractWhereDSL() {
30+
super();
31+
}
32+
2933
protected <S> AbstractWhereDSL(BindableColumn<S> column, VisitableCondition<S> condition) {
3034
SqlCriterion<S> criterion = SqlCriterion.withColumn(column)
3135
.withCondition(condition)

src/main/java/org/mybatis/dynamic/sql/where/WhereDSL.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,10 @@
2121

2222
public class WhereDSL extends AbstractWhereDSL<WhereDSL> {
2323

24+
private WhereDSL() {
25+
super();
26+
}
27+
2428
private <T> WhereDSL(BindableColumn<T> column, VisitableCondition<T> condition) {
2529
super(column, condition);
2630
}
@@ -34,6 +38,10 @@ protected WhereDSL getThis() {
3438
return this;
3539
}
3640

41+
public static WhereDSL where() {
42+
return new WhereDSL();
43+
}
44+
3745
public static <T> WhereDSL where(BindableColumn<T> column, VisitableCondition<T> condition) {
3846
return new WhereDSL(column, condition);
3947
}

0 commit comments

Comments
 (0)