*
* @param preparing whether a filter for the prepare phase should be made
* @return the filter
*/
private Filter createFilter(boolean preparing) {
FilterImpl f = new FilterImpl(this, query.getStatement(), query.getRootTree());
f.setPreparing(preparing);
if (joinCondition != null) {
joinCondition.restrict(f);
}
// rep:excerpt handling: create a (fake) restriction
// "rep:excerpt is not null" to let the index know that
// we will need the excerpt
for (ColumnImpl c : query.getColumns()) {
if (c.getSelector() == this) {
if (c.getColumnName().equals("rep:excerpt")) {
f.restrictProperty("rep:excerpt", Operator.NOT_EQUAL, null);
}
}
}
// all conditions can be pushed to the selectors -
// except in some cases to "outer joined" selectors,
// but the exceptions are handled in the condition
// itself.
// An example where it *is* a problem:
// "select * from a left outer join b on a.x = b.y
// where b.y is null" - in this case the selector b
// must not use an index condition on "y is null"
// (".. is null" must be written as "not .. is not null").
if (queryConstraint != null) {
queryConstraint.restrict(f);
FullTextExpression ft = queryConstraint.getFullTextConstraint(this);
f.setFullTextConstraint(ft);
}
return f;
}