#728 - Remove Query.where(String) ... migrate to where().raw(...)

This commit is contained in:
Robin Bygrave committed 2016-06-01 19:54:02 +12:00
1 parent 71f70c01ae
commit 92caf69cb3
9 files changed
+106 -505

No files matched your search

@@ -81,11 +81,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
*/
private int lazyLoadBatchSize;
/**
* The where clause from a parsed query string.
*/
private String rawWhereClause;
private OrderBy<T> orderBy;
private String loadMode;
@@ -99,10 +94,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
*/
private String query;
private String additionalWhere;
private String additionalHaving;
private String lazyLoadProperty;
private String lazyLoadManyPath;
@@ -563,8 +554,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
copy.query = query;
copy.rootTableAlias = rootTableAlias;
copy.additionalWhere = additionalWhere;
copy.additionalHaving = additionalHaving;
copy.distinct = distinct;
copy.sqlDistinct = sqlDistinct;
copy.timeout = timeout;
@@ -580,7 +569,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
copy.temporalMode = temporalMode;
copy.firstRow = firstRow;
copy.maxRows = maxRows;
copy.rawWhereClause = rawWhereClause;
if (orderBy != null) {
copy.orderBy = orderBy.copy();
}
@@ -599,7 +587,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
copy.parentNode = parentNode;
copy.forUpdate = forUpdate;
copy.rawSql = rawSql;
copy.rawWhereClause = rawWhereClause;
return copy;
}
@@ -831,7 +818,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
CQueryPlanKey createQueryPlanKey() {
queryPlanKey = new OrmQueryPlanKey(includeTableJoin, type, detail, maxRows, firstRow,
disableLazyLoading, rawWhereClause, orderBy, query, additionalWhere, additionalHaving,
disableLazyLoading, orderBy, query,
distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions,
temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties);
@@ -901,14 +888,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return rawSql != null;
}
/**
* Return any additional where clauses.
*/
@Override
public String getAdditionalWhere() {
return additionalWhere;
}
/**
* Return the timeout.
*/
@@ -917,14 +896,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return timeout;
}
/**
* Return any additional having clauses.
*/
@Override
public String getAdditionalHaving() {
return additionalHaving;
}
@Override
public boolean hasMaxRowsOrFirstRow() {
return maxRows > 0 || firstRow > 0;
@@ -1002,10 +973,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return this;
}
protected void setRawWhereClause(String rawWhereClause) {
this.rawWhereClause = rawWhereClause;
}
@Override
public DefaultOrmQuery<T> select(String columns) {
detail.select(columns);
@@ -1164,14 +1131,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return orderBy;
}
/**
* Return the order by clause.
*/
@Override
public String getRawWhereClause() {
return rawWhereClause;
}
@Override
public OrderBy<T> orderBy() {
return order();
@@ -1335,22 +1294,9 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return query;
}
@Override
public DefaultOrmQuery<T> where(String addToWhereClause) {
if (additionalWhere == null) {
additionalWhere = addToWhereClause;
} else {
additionalWhere += " " + addToWhereClause;
}
return this;
}
@Override
public DefaultOrmQuery<T> where(Expression expression) {
if (whereExpressions == null) {
whereExpressions = new DefaultExpressionList<T>(this, null);
}
whereExpressions.add(expression);
where().add(expression);
return this;
}
@@ -1371,22 +1317,9 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return whereExpressions;
}
@Override
public DefaultOrmQuery<T> having(String addToHavingClause) {
if (additionalHaving == null) {
additionalHaving = addToHavingClause;
} else {
additionalHaving += " " + addToHavingClause;
}
return this;
}
@Override
public DefaultOrmQuery<T> having(Expression expression) {
if (havingExpressions == null) {
havingExpressions = new DefaultExpressionList<T>(this, null);
}
havingExpressions.add(expression);
having().add(expression);
return this;
}
@@ -36,14 +36,6 @@ public class OrmQueryDetailParser {
return detail;
}
protected void assign(DefaultOrmQuery<?> query) {
query.setOrmQueryDetail(detail);
query.setFirstRow(firstRow);
query.setMaxRows(maxRows);
query.setRawWhereClause(rawWhereClause);
query.order(rawOrderBy);
}
private void processInitial() {
if (parser.isMatch("select")) {
readSelect();
@@ -25,10 +25,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
private final int maxRows;
private final int firstRow;
private final boolean disableLazyLoading;
private final String rawWhereClause;
private final String query;
private final String additionalWhere;
private final String additionalHaving;
private final boolean distinct;
private final boolean sqlDistinct;
private final String mapKey;
@@ -40,7 +37,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
private final int planHash;
private final int bindCount;
public OrmQueryPlanKey(TableJoin includeTableJoin, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, String rawWhereClause, OrderBy<?> orderBy, String query, String additionalWhere, String additionalHaving, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) {
public OrmQueryPlanKey(TableJoin includeTableJoin, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy<?> orderBy, String query, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) {
this.includeTableJoin = includeTableJoin;
this.type = type;
@@ -48,11 +45,8 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
this.maxRows = maxRows;
this.firstRow = firstRow;
this.disableLazyLoading = disableLazyLoading;
this.rawWhereClause = rawWhereClause;
this.orderByAsSting = (orderBy == null) ? null : orderBy.toStringFormat();
this.query = query;
this.additionalWhere = additionalWhere;
this.additionalHaving = additionalHaving;
this.distinct = distinct;
this.sqlDistinct = sqlDistinct;
this.mapKey = mapKey;
@@ -72,7 +66,6 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
builder.add(distinct).add(sqlDistinct).add(query);
builder.add(firstRow).add(maxRows);
builder.add(orderBy).add(forUpdate);
builder.add(rawWhereClause).add(additionalWhere).add(additionalHaving);
builder.add(mapKey);
builder.add(disableLazyLoading);
builder.add(hasIdValue);
@@ -138,10 +131,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
// if (detail != null ? !detail.equals(that.detail) : that.detail != null) return false;
if (rawWhereClause != null ? !rawWhereClause.equals(that.rawWhereClause) : that.rawWhereClause != null) return false;
if (query != null ? !query.equals(that.query) : that.query != null) return false;
if (additionalWhere != null ? !additionalWhere.equals(that.additionalWhere) : that.additionalWhere != null) return false;
if (additionalHaving != null ? !additionalHaving.equals(that.additionalHaving) : that.additionalHaving != null) return false;
if (mapKey != null ? !mapKey.equals(that.mapKey) : that.mapKey != null) return false;
return rootTableAlias != null ? rootTableAlias.equals(that.rootTableAlias) : that.rootTableAlias == null;
}