private Condition getContainsCondition(Object value, BiPredicate<?, ?> biPredicate, Field<Object> field) { if (biPredicate == Contains.without) { if (value == null) { return field.isNull(); } else { return field.notIn(value); } } else if (biPredicate == Contains.within) { if (value == null) { return field.isNotNull(); } else { return field.in(((Collection) value).toArray()); } } return null; }
private final QueryPartInternal delegate(Configuration configuration) { // CUBRID 9.0.0 and HSQLDB have buggy implementations of the NULL predicate. // Informix doesn't implement the RVE IS NULL predicate. if (EMULATE_NULL.contains(configuration.family())) { Field<?>[] fields = row.fields(); List<Condition> conditions = new ArrayList<Condition>(fields.length); for (Field<?> field : fields) conditions.add(isNull ? field.isNull() : field.isNotNull()); Condition result = DSL.and(conditions); return (QueryPartInternal) result; } else { return new Native(); } }
private final QueryPartInternal delegate(Configuration configuration) { // CUBRID 9.0.0 and HSQLDB have buggy implementations of the NULL predicate. // Let's wait for them to be fixed if (asList(CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, SQLITE).contains(configuration.dialect().family())) { List<Condition> conditions = new ArrayList<Condition>(); for (Field<?> field : row.fields()) { conditions.add(isNull ? field.isNull() : field.isNotNull()); } Condition result = new CombinedCondition(Operator.AND, conditions); return (QueryPartInternal) result; } else { return new Native(); } }
@Override public Select getSearch(SearchQuery<Edge> query, PredicatesHolder predicatesHolder) { SelectJoinStep search = (SelectJoinStep) super.getSearch(query, predicatesHolder); if (search == null) return null; return search.where(field(this.getFieldByPropertyKey(T.id.getAccessor())).isNotNull()); }
Condition fieldMatchesUserPermission(Field<String> field, String userPermission) { return DSL.or( field.eq(userPermission), DSL.and( field.isNotNull(), field.notEqual(""), field.likeRegex(PERMISSION_START_REGEX + userPermission + PERMISSION_END_REGEX) ) ); }
@Override final Field<T> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { case H2: case HSQLDB: return DSL.field("{nvl2}({0}, {1}, {2})", getDataType(), arg1, arg2, arg3); default: return DSL.when(arg1.isNotNull(), arg2).otherwise(arg3); } } }
protected Condition toCondition(Part part, Iterator<Object> iterator) { String property = part.getProperty().toDotPath(); Field<Object> field = field(property); switch (part.getType()) { case AFTER: case GREATER_THAN: return field.gt(iterator.next()); case GREATER_THAN_EQUAL: return field.ge(iterator.next()); case BEFORE: case LESS_THAN: return field.lt(iterator.next()); case LESS_THAN_EQUAL: return field.le(iterator.next()); case BETWEEN: return field.between(iterator.next(), iterator.next()); case IS_NULL: return field.isNull(); case IS_NOT_NULL: return field.isNotNull(); case IN: return field.in(toList(iterator)); case NOT_IN: return field.notIn(toList(iterator)); case LIKE: return lowerIfIgnoreCase(part, field, iterator); case NOT_LIKE: return lowerIfIgnoreCase(part, field, iterator).not(); case STARTING_WITH: return field.startsWith(iterator.next()); case ENDING_WITH: return field.endsWith(iterator.next()); case CONTAINING: return field.contains(iterator.next()); case SIMPLE_PROPERTY: return field.eq(iterator.next()); case NEGATING_SIMPLE_PROPERTY: return field.ne(iterator.next()); case TRUE: return field.eq(true); case FALSE: return field.eq(false); default: throw new IllegalArgumentException("Unsupported keyword!"); } }
private Condition fieldMatchesPermission(Field<Object> field, Object permission) { //For now only support strings if(!(permission instanceof String)) return DSL.falseCondition(); return DSL.or( field.eq(permission), DSL.and( field.isNotNull(), field.notEqual(""), field.likeRegex(PERMISSION_START_REGEX + permission + PERMISSION_END_REGEX) ) ); }
case "ne": if (firstArg == null) { return field.isNotNull();
private Condition extractCondition(HasContainer hasContainer) { String key = hasContainer.getKey(); P predicate = hasContainer.getPredicate(); Object value = predicate.getValue(); BiPredicate<?, ?> biPredicate = predicate.getBiPredicate(); Field<Object> field = field(key); if (predicate instanceof ConnectiveP){ return handleConnectiveP(key, (ConnectiveP) predicate); } else if (predicate instanceof ExistsP) { return field.isNotNull(); } else return predicateToQuery(key, value, biPredicate); }
@Override final Field<T> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxxxxx xx [/pro] */ case H2: case HSQLDB: return field("{nvl2}({0}, {1}, {2})", getDataType(), arg1, arg2, arg3); default: return DSL.decode().when(arg1.isNotNull(), arg2).otherwise(arg3); } } }
return field.isNull(); case IS_NOT_NULL: return field.isNotNull(); case IN: return field.in(toList(iterator));
return DSL.when(arg1.isNotNull(), arg1).otherwise(arg2);
@Override final Field<T> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxxxx xxxxxxxxxxxxxxxx xx xxxxx xxxx xxxxxx xxxxxxxxxxxxxx xxxxx xxxxxx xxxx xxxx xxxx xxxxxxx xxxx xxxxxxx xx [/pro] */ case H2: case HSQLDB: return field("{nvl}({0}, {1})", getDataType(), arg1, arg2); case DERBY: case POSTGRES: return field("{coalesce}({0}, {1})", getDataType(), arg1, arg2); case MARIADB: case MYSQL: case SQLITE: return field("{ifnull}({0}, {1})", getDataType(), arg1, arg2); default: return DSL.decode().when(arg1.isNotNull(), arg1).otherwise(arg2); } } }
caseExpression = (QueryPartInternal) decode() .when(lhs.isNull().and(rhs.isNull()), zero()) .when(lhs.isNull().and(rhs.isNotNull()), one()) .when(lhs.isNotNull().and(rhs.isNull()), one()) .when(lhs.equal(rhs), zero()) .otherwise(one()) caseExpression = (QueryPartInternal) decode() .when(lhs.isNull().and(rhs.isNull()), one()) .when(lhs.isNull().and(rhs.isNotNull()), zero()) .when(lhs.isNotNull().and(rhs.isNull()), zero()) .when(lhs.equal(rhs), one()) .otherwise(zero())
return not ? left instanceof Field ? ((Field) left).isNotNull() : ((RowN) left).isNotNull() : left instanceof Field