Skip to content

Commit 605604f

Browse files
committed
Added fix for where("x", null) to internally call whereNull instead
1 parent f013f39 commit 605604f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/javawebstack/orm/query/QueryGroup.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public QueryGroup<T> or(Function<QueryGroup<T>, QueryGroup<T>> group) {
3838
}
3939

4040
public QueryGroup<T> where(Object left, String condition, Object right) {
41-
if(right == null)
41+
if(condition.equalsIgnoreCase("=") && right == null)
4242
return whereNull(left);
43+
if(condition.equalsIgnoreCase("!=") && right == null)
44+
return whereNotNull(left);
4345
if (queryElements.size() > 0)
4446
queryElements.add(QueryConjunction.AND);
4547
queryElements.add(new QueryCondition(left instanceof String ? new QueryColumn((String) left) : left, condition, right));
@@ -99,8 +101,10 @@ public QueryGroup<T> greaterThan(Object left, Object right) {
99101
}
100102

101103
public QueryGroup<T> orWhere(Object left, String condition, Object right) {
102-
if(right == null)
104+
if(condition.equalsIgnoreCase("=") && right == null)
103105
return orIsNull(left);
106+
if(condition.equalsIgnoreCase("!=") && right == null)
107+
return orNotNull(left);
104108
if (queryElements.size() > 0)
105109
queryElements.add(QueryConjunction.OR);
106110
queryElements.add(new QueryCondition(left instanceof String ? new QueryColumn((String) left) : left, condition, right));

0 commit comments

Comments
 (0)