#715 - isNull() expression on @OneToMany or @ManyToMany produces incorrect SQL - should translate this to be same as isEmpty() and result in exists subquery

This commit is contained in:
Robin Bygrave
2016-05-20 17:53:11 +12:00
parent 0510304c0f
commit a20822a9e1
12 changed files with 171 additions and 55 deletions
@@ -50,10 +50,17 @@ class IsEmptyExpression extends AbstractExpression {
throw new IllegalStateException("Property [" + propName + "] not found");
}
isEmptySql(request, prop, empty, propertyPath);
}
/**
* Append an exists subQuery for the property.
*/
static void isEmptySql(SpiExpressionRequest request, ElPropertyValue prop, boolean empty, String propertyPath) {
if (empty) {
request.append("not ");
}
request
.append("exists (select 1 from ")
.append(prop.getAssocIsEmpty(request, propertyPath))