Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support for wrapper values being autounboxed for constructors wit…
…h primitives in Wirings Remove the need for execute() call on query building Support complex conditions with conjunctions and creating sub-expressions joined by conjunctions
- Loading branch information
Showing
11 changed files
with
450 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 29 additions & 12 deletions
41
core/src/main/java/foundation/stack/datamill/db/ConditionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
package foundation.stack.datamill.db; | ||
|
||
import foundation.stack.datamill.reflection.Member; | ||
import rx.functions.Func1; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public interface ConditionBuilder<R> { | ||
<T> WhereBuilder<R> eq(String column, T value); | ||
<T> WhereBuilder<R> eq(String table, String column, T value); | ||
<T> WhereBuilder<R> eq(Member member, T value); | ||
|
||
<T> WhereBuilder<R> is(String column, T value); | ||
<T> WhereBuilder<R> is(String table, String column, T value); | ||
<T> WhereBuilder<R> is(Member member, T value); | ||
|
||
<T> WhereBuilder<R> in(String column, Collection<T> value); | ||
<T> WhereBuilder<R> in(String table, String column, Collection<T> value); | ||
<T> WhereBuilder<R> in(Member member, Collection<T> value); | ||
public interface ConditionBuilder { | ||
<T> ConjunctionBuilder eq(String column, T value); | ||
<T> ConjunctionBuilder eq(String table, String column, T value); | ||
<T> ConjunctionBuilder eq(Member member, T value); | ||
|
||
<T> ConjunctionBuilder lt(String column, T value); | ||
<T> ConjunctionBuilder lt(String table, String column, T value); | ||
<T> ConjunctionBuilder lt(Member member, T value); | ||
|
||
<T> ConjunctionBuilder gt(String column, T value); | ||
<T> ConjunctionBuilder gt(String table, String column, T value); | ||
<T> ConjunctionBuilder gt(Member member, T value); | ||
|
||
<T> ConjunctionBuilder is(String column, T value); | ||
<T> ConjunctionBuilder is(String table, String column, T value); | ||
<T> ConjunctionBuilder is(Member member, T value); | ||
|
||
<T> ConjunctionBuilder in(String column, Collection<T> value); | ||
<T> ConjunctionBuilder in(String table, String column, Collection<T> value); | ||
<T> ConjunctionBuilder in(Member member, Collection<T> value); | ||
|
||
TerminalCondition and( | ||
Func1<ConditionBuilder, TerminalCondition> left, | ||
Func1<ConditionBuilder, TerminalCondition> right); | ||
|
||
TerminalCondition or( | ||
Func1<ConditionBuilder, TerminalCondition> left, | ||
Func1<ConditionBuilder, TerminalCondition> right); | ||
} |
9 changes: 9 additions & 0 deletions
9
core/src/main/java/foundation/stack/datamill/db/ConjunctionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package foundation.stack.datamill.db; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public interface ConjunctionBuilder extends TerminalCondition { | ||
ConditionBuilder and(); | ||
ConditionBuilder or(); | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/foundation/stack/datamill/db/TerminalCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foundation.stack.datamill.db; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public interface TerminalCondition { | ||
} |
5 changes: 2 additions & 3 deletions
5
core/src/main/java/foundation/stack/datamill/db/WhereBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
package foundation.stack.datamill.db; | ||
|
||
import foundation.stack.datamill.reflection.Outline; | ||
import rx.functions.Func1; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public interface WhereBuilder<R> { | ||
R all(); | ||
R execute(); | ||
ConditionBuilder<R> where(); | ||
ConditionBuilder<R> and(); | ||
R where(Func1<ConditionBuilder, TerminalCondition> conditionBuilder); | ||
JoinBuilder<R> leftJoin(String table); | ||
JoinBuilder<R> leftJoin(Outline<?> outline); | ||
} |
34 changes: 34 additions & 0 deletions
34
core/src/main/java/foundation/stack/datamill/db/impl/EmptyUpdateSuffixBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package foundation.stack.datamill.db.impl; | ||
|
||
import foundation.stack.datamill.db.InsertSuffixBuilder; | ||
import foundation.stack.datamill.db.RowBuilder; | ||
import foundation.stack.datamill.db.UpdateQueryExecution; | ||
import rx.Observable; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
class EmptyUpdateSuffixBuilder implements InsertSuffixBuilder { | ||
@Override | ||
public Observable<Integer> count() { | ||
return Observable.just(0); | ||
} | ||
|
||
@Override | ||
public Observable<Long> getIds() { | ||
return Observable.empty(); | ||
} | ||
|
||
@Override | ||
public UpdateQueryExecution onDuplicateKeyUpdate(Function<RowBuilder, Map<String, ?>> rowConstructor) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public UpdateQueryExecution onDuplicateKeyUpdate(Map<String, ?> values) { | ||
return this; | ||
} | ||
} |
Oops, something went wrong.