parent
6a8a77a528
commit
7c5f29de00
@ -1423,28 +1423,29 @@ public interface Field<T> extends SelectField<T>, GroupField, FieldOrRow {
|
||||
Condition notContains(Field<T> value);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #likeIgnoreCase(String, char)} including proper
|
||||
* adding of wildcards and escaping.
|
||||
*
|
||||
* Convenience method for {@link #likeIgnoreCase(String, char)} including
|
||||
* proper adding of wildcards and escaping.
|
||||
* <p>
|
||||
* This translates to <code>this not ilike ('%' || escape(value, '\') || '%') escape '\'</code>
|
||||
* in {@link SQLDialect#POSTGRES}, or to
|
||||
* This translates to
|
||||
* <code>this ilike ('%' || escape(value, '\') || '%') escape '\'</code> in
|
||||
* {@link SQLDialect#POSTGRES}, or to
|
||||
* <code>lower(this) not like lower(('%' || escape(value, '\') || '%') escape '\')</code>
|
||||
* in all other dialects.
|
||||
* </p>
|
||||
*
|
||||
* @see DSL#escape(Field, char)
|
||||
* @see #likeIgnoreCase(Field, char)
|
||||
* @see #likeIgnoreCase(String, char)
|
||||
* @see #contains(Object)
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
Condition containsIgnoreCase(T value);
|
||||
Condition containsIgnoreCase(T value);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #likeIgnoreCase(String, char)} including proper
|
||||
* adding of wildcards and escaping.
|
||||
*
|
||||
* Convenience method for {@link #likeIgnoreCase(String, char)} including
|
||||
* proper adding of wildcards and escaping.
|
||||
* <p>
|
||||
* This translates to <code>this not ilike ('%' || escape(value, '\') || '%') escape '\'</code>
|
||||
* This translates to
|
||||
* <code>this not ilike ('%' || escape(value, '\') || '%') escape '\'</code>
|
||||
* in {@link SQLDialect#POSTGRES}, or to
|
||||
* <code>lower(this) not like lower(('%' || escape(value, '\') || '%') escape '\')</code>
|
||||
* in all other dialects.
|
||||
@ -1452,23 +1453,24 @@ public interface Field<T> extends SelectField<T>, GroupField, FieldOrRow {
|
||||
*
|
||||
* @see DSL#escape(Field, char)
|
||||
* @see #likeIgnoreCase(Field, char)
|
||||
* @see #contains(Field)
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
Condition containsIgnoreCase(Field<T> value);
|
||||
Condition containsIgnoreCase(Field<T> value);
|
||||
|
||||
/**
|
||||
* Inverse of {@link #containsIgnoreCase(Object)}
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
Condition notContainsIgnoreCase(T value);
|
||||
Condition notContainsIgnoreCase(T value);
|
||||
|
||||
/**
|
||||
* Inverse of {@link #containsIgnoreCase(Field)}
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
Condition notContainsIgnoreCase(Field<T> value);
|
||||
Condition notContainsIgnoreCase(Field<T> value);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convenience method for {@link #like(String, char)} including proper
|
||||
* adding of wildcards and escaping.
|
||||
* <p>
|
||||
|
||||
@ -837,12 +837,12 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
|
||||
@Override
|
||||
public final Condition containsIgnoreCase(T value) {
|
||||
return new ContainsIgnoreCase<>(this, value);
|
||||
return new ContainsIgnoreCase<T>(this, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition containsIgnoreCase(Field<T> value) {
|
||||
return new ContainsIgnoreCase<>(this, value);
|
||||
return new ContainsIgnoreCase<T>(this, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -51,49 +51,49 @@ import org.jooq.Field;
|
||||
*/
|
||||
final class ContainsIgnoreCase<T> extends AbstractCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1795491010886118843L;
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1795491010886118843L;
|
||||
|
||||
private static final Clause[] CLAUSES = {CONDITION, CONDITION_COMPARISON};
|
||||
private static final Clause[] CLAUSES = { CONDITION, CONDITION_COMPARISON };
|
||||
|
||||
private final Field<T> lhs;
|
||||
private final Field<T> rhs;
|
||||
private final T value;
|
||||
private final Field<T> lhs;
|
||||
private final Field<T> rhs;
|
||||
private final T value;
|
||||
|
||||
ContainsIgnoreCase(Field<T> field, T value) {
|
||||
this.lhs = field;
|
||||
this.rhs = null;
|
||||
this.value = value;
|
||||
}
|
||||
ContainsIgnoreCase(Field<T> field, T value) {
|
||||
this.lhs = field;
|
||||
this.rhs = null;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
ContainsIgnoreCase(Field<T> field, Field<T> rhs) {
|
||||
this.lhs = field;
|
||||
this.rhs = rhs;
|
||||
this.value = null;
|
||||
}
|
||||
ContainsIgnoreCase(Field<T> field, Field<T> rhs) {
|
||||
this.lhs = field;
|
||||
this.rhs = rhs;
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(condition(ctx.configuration()));
|
||||
}
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(condition(ctx.configuration()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
private final Condition condition(Configuration configuration) {
|
||||
private final Condition condition(Configuration configuration) {
|
||||
Field<String> concat;
|
||||
|
||||
Field<String> concat;
|
||||
if (rhs == null) {
|
||||
concat = DSL.concat(inline("%"), Tools.escapeForLike(value, configuration), inline("%"));
|
||||
}
|
||||
else {
|
||||
concat = DSL.concat(inline("%"), Tools.escapeForLike(rhs, configuration), inline("%"));
|
||||
}
|
||||
|
||||
if (rhs == null) {
|
||||
concat = DSL.concat(inline("%"), Tools.escapeForLike(value, configuration), inline("%"));
|
||||
} else {
|
||||
concat = DSL.concat(inline("%"), Tools.escapeForLike(rhs, configuration), inline("%"));
|
||||
}
|
||||
|
||||
return lhs.likeIgnoreCase(concat, Tools.ESCAPE);
|
||||
}
|
||||
return lhs.likeIgnoreCase(concat, Tools.ESCAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ Authors and contributors of jOOQ or parts of jOOQ in alphabetical order:
|
||||
- Joseph B Phillips
|
||||
- Joseph Pachod
|
||||
- Laurent Pireyn
|
||||
- Luc Marchaud
|
||||
- Lukas Eder
|
||||
- Matti Tahvonen
|
||||
- Michael Doberenz
|
||||
|
||||
Loading…
Reference in New Issue
Block a user