if (item.isCompoundFilter()) {
FilterItem[] childItems = item.getChildItems();
StringBuilder sb = new StringBuilder();
sb.append('(');
for (int i = 0; i < childItems.length; i++) {
FilterItem child = childItems[i];
if (i != 0) {
sb.append(' ');
sb.append(item.getLogicalOperator().toString());
sb.append(' ');
}
sb.append(rewriteFilterItem(child));
}
sb.append(')');
return sb.toString();
}
final String primaryFilterSql = item.toSql(isSchemaIncludedInColumnPaths());
final OperatorType operator = item.getOperator();
if (operator == OperatorType.DIFFERENT_FROM) {
final Object operand = item.getOperand();
if (operand != null) {
// special case in SQL where NULL is not treated as a value -
// see Ticket #1058
FilterItem isNullFilter = new FilterItem(item.getSelectItem(), OperatorType.EQUALS_TO, null);
final String secondaryFilterSql = rewriteFilterItem(isNullFilter);
return '(' + primaryFilterSql + " OR " + secondaryFilterSql + ')';
}
}