mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1256 - Query where many isNotEmpty() ... on ManyToMany with SoftDelete produces incorrect SQL (Part 2)
This commit is contained in:
@@ -37,6 +37,8 @@ public abstract class DeployParser {
|
||||
|
||||
protected int pos;
|
||||
|
||||
protected String priorWord;
|
||||
|
||||
protected String word;
|
||||
|
||||
protected char wordTerminator;
|
||||
@@ -45,7 +47,6 @@ public abstract class DeployParser {
|
||||
|
||||
public abstract String getDeployWord(String expression);
|
||||
|
||||
|
||||
/**
|
||||
* Return the join includes.
|
||||
*/
|
||||
@@ -67,8 +68,14 @@ public abstract class DeployParser {
|
||||
this.sb = new StringBuilder(source.length() + 20);
|
||||
|
||||
while (nextWord()) {
|
||||
String deployWord = convertWord();
|
||||
sb.append(deployWord);
|
||||
if (skipWordConvert()) {
|
||||
sb.append(word);
|
||||
priorWord = word;
|
||||
} else {
|
||||
String deployWord = convertWord();
|
||||
sb.append(deployWord);
|
||||
priorWord = deployWord;
|
||||
}
|
||||
if (pos < sourceLength) {
|
||||
sb.append(wordTerminator);
|
||||
if (wordTerminator == SINGLE_QUOTE) {
|
||||
@@ -80,6 +87,10 @@ public abstract class DeployParser {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected boolean skipWordConvert() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean nextWord() {
|
||||
|
||||
if (!findWordStart()) {
|
||||
|
||||
@@ -14,12 +14,15 @@ import java.util.Set;
|
||||
*/
|
||||
public final class DeployPropertyParser extends DeployParser {
|
||||
|
||||
private static final String JOIN = "join";
|
||||
|
||||
private static final String FROM = "from";
|
||||
|
||||
private final BeanDescriptor<?> beanDescriptor;
|
||||
|
||||
private final Set<String> includes = new HashSet<>();
|
||||
|
||||
public DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
|
||||
DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
|
||||
this.beanDescriptor = beanDescriptor;
|
||||
}
|
||||
|
||||
@@ -28,6 +31,13 @@ public final class DeployPropertyParser extends DeployParser {
|
||||
return includes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip if in raw sql expression with from tableName or join tableName.
|
||||
*/
|
||||
protected boolean skipWordConvert() {
|
||||
return FROM.equalsIgnoreCase(priorWord) || JOIN.equalsIgnoreCase(priorWord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeployWord(String expression) {
|
||||
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.api.BindParams;
|
||||
import io.ebeaninternal.api.SpiExpressionList;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
@@ -12,6 +11,7 @@ import io.ebeaninternal.server.expression.DefaultExpressionRequest;
|
||||
import io.ebeaninternal.server.persist.Binder;
|
||||
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
import io.ebeaninternal.server.querydefn.OrmUpdateProperties;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.util.BindParamsParser;
|
||||
import org.slf4j.Logger;
|
||||
@@ -318,15 +318,9 @@ public class CQueryPredicates {
|
||||
}
|
||||
|
||||
private String parse(String expr, DeployParser deployParser) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!isEmpty(expr)) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append(deployParser.parse(expr));
|
||||
}
|
||||
return sb.toString();
|
||||
if (expr == null) return "";
|
||||
if (expr.isEmpty()) return expr;
|
||||
return deployParser.parse(expr);
|
||||
}
|
||||
|
||||
private String deriveHaving(DeployParser deployParser) {
|
||||
|
||||
Reference in New Issue
Block a user