Skip to content

Add support for calling where with no parameters #108

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

Merged
merged 2 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ static UpdateDSL<UpdateModel> update(SqlTable table) {
return UpdateDSL.update(table);
}

static WhereDSL where() {
return WhereDSL.where();
}

static <T> WhereDSL where(BindableColumn<T> column, VisitableCondition<T> condition) {
return WhereDSL.where(column, condition);
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/mybatis/dynamic/sql/delete/DeleteDSL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +35,10 @@ private DeleteDSL(SqlTable table, Function<DeleteModel, R> adapterFunction) {
this.adapterFunction = Objects.requireNonNull(adapterFunction);
}

public DeleteWhereBuilder where() {
return new DeleteWhereBuilder();
}

public <T> DeleteWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
return new DeleteWhereBuilder(column, condition);
}
Expand Down Expand Up @@ -70,6 +74,10 @@ public static <T> DeleteDSL<MyBatis3DeleteModelAdapter<T>> deleteFromWithMapper(

public class DeleteWhereBuilder extends AbstractWhereDSL<DeleteWhereBuilder> {

private <T> DeleteWhereBuilder() {
super();
}

private <T> DeleteWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
super(column, condition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public static <R> FromGatherer<R> selectDistinct(SelectDSL<R> selectDSL, BasicCo
.build();
}

public QueryExpressionWhereBuilder where() {
return new QueryExpressionWhereBuilder();
}

public <T> QueryExpressionWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
return new QueryExpressionWhereBuilder(column, condition);
}
Expand Down Expand Up @@ -261,6 +265,10 @@ public FromGatherer<R> build() {

public class QueryExpressionWhereBuilder extends AbstractWhereDSL<QueryExpressionWhereBuilder>
implements Buildable<R> {
private <T> QueryExpressionWhereBuilder() {
buildDelegateMethod = this::internalBuild;
}

private <T> QueryExpressionWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
super(column, condition);
buildDelegateMethod = this::internalBuild;
Expand Down Expand Up @@ -413,6 +421,11 @@ private R internalbuild() {
return selectDSL.build();
}

public QueryExpressionWhereBuilder where() {
joinModel = buildJoinModel();
return new QueryExpressionWhereBuilder();
}

public <T> QueryExpressionWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
joinModel = buildJoinModel();
return new QueryExpressionWhereBuilder(column, condition);
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/mybatis/dynamic/sql/update/UpdateDSL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,10 @@ public <T> SetClauseFinisher<T> set(SqlColumn<T> column) {
return new SetClauseFinisher<>(column);
}

public UpdateWhereBuilder where() {
return new UpdateWhereBuilder();
}

public <T> UpdateWhereBuilder where(BindableColumn<T> column, VisitableCondition<T> condition) {
return new UpdateWhereBuilder(column, condition);
}
Expand Down Expand Up @@ -145,6 +149,10 @@ public UpdateDSL<R> equalToWhenPresent(Supplier<T> valueSupplier) {

public class UpdateWhereBuilder extends AbstractWhereDSL<UpdateWhereBuilder> {

public <T> UpdateWhereBuilder() {
super();
}

public <T> UpdateWhereBuilder(BindableColumn<T> column, VisitableCondition<T> condition) {
super(column, condition);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +26,10 @@
public abstract class AbstractWhereDSL<T extends AbstractWhereDSL<T>> {
private List<SqlCriterion<?>> criteria = new ArrayList<>();

protected <S> AbstractWhereDSL() {
super();
}

protected <S> AbstractWhereDSL(BindableColumn<S> column, VisitableCondition<S> condition) {
SqlCriterion<S> criterion = SqlCriterion.withColumn(column)
.withCondition(condition)
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/mybatis/dynamic/sql/where/WhereDSL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,10 @@

public class WhereDSL extends AbstractWhereDSL<WhereDSL> {

private WhereDSL() {
super();
}

private <T> WhereDSL(BindableColumn<T> column, VisitableCondition<T> condition) {
super(column, condition);
}
Expand All @@ -34,6 +38,10 @@ protected WhereDSL getThis() {
return this;
}

public static WhereDSL where() {
return new WhereDSL();
}

public static <T> WhereDSL where(BindableColumn<T> column, VisitableCondition<T> condition) {
return new WhereDSL(column, condition);
}
Expand Down
Loading