[#1697] Add Factory.all() and Factory.any() to create quantified
expressions
This commit is contained in:
parent
95b8db9cce
commit
bd7d135140
@ -42,6 +42,8 @@ import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
import static org.jooq.conf.StatementType.STATIC_STATEMENT;
|
||||
import static org.jooq.impl.Factory.all;
|
||||
import static org.jooq.impl.Factory.any;
|
||||
import static org.jooq.impl.Factory.castNull;
|
||||
import static org.jooq.impl.Factory.concat;
|
||||
import static org.jooq.impl.Factory.count;
|
||||
@ -494,41 +496,41 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
// Testing = ALL(subquery)
|
||||
assertEquals(Arrays.asList(1), create().select()
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAll(create().selectOne()))
|
||||
.where(TBook_ID().equal(all(create().selectOne())))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
assertEquals(Arrays.asList(), create().select()
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAll(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2))))
|
||||
.where(TBook_ID().equal(all(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2)))))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
|
||||
// Testing = ANY(subquery)
|
||||
assertEquals(Arrays.asList(1), create().select()
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAny(create().selectOne()))
|
||||
.where(TBook_ID().equal(any(create().selectOne())))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
assertEquals(Arrays.asList(1, 2), create().select()
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2))))
|
||||
.where(TBook_ID().equal(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2)))))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
|
||||
// Testing = ALL(array)
|
||||
assertEquals(Arrays.asList(1), create().select(TBook_ID())
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAll(1))
|
||||
.where(TBook_ID().equal(all(1)))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
assertEquals(Arrays.asList(), create().select(TBook_ID())
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAll(1, 2))
|
||||
.where(TBook_ID().equal(all(1, 2)))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
|
||||
// Testing = ANY(array)
|
||||
assertEquals(Arrays.asList(1), create().select(TBook_ID())
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAny(1))
|
||||
.where(TBook_ID().equal(any(1)))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
assertEquals(Arrays.asList(1, 2), create().select(TBook_ID())
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equalAny(1, 2))
|
||||
.where(TBook_ID().equal(any(1, 2)))
|
||||
.orderBy(TBook_ID()).fetch(TBook_ID()));
|
||||
|
||||
// Inducing the above to work the same way as all other operators
|
||||
@ -537,35 +539,35 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
.select()
|
||||
.from(TBook())
|
||||
.where(TBook_ID().equal(create().select(val(3))))
|
||||
.and(TBook_ID().equalAll(create().select(val(3))))
|
||||
.and(TBook_ID().equalAll(3, 3))
|
||||
.and(TBook_ID().equalAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(3, 4))))
|
||||
.and(TBook_ID().equalAny(3, 4))
|
||||
.and(TBook_ID().equal(all(create().select(val(3)))))
|
||||
.and(TBook_ID().equal(all(3, 3)))
|
||||
.and(TBook_ID().equal(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(3, 4)))))
|
||||
.and(TBook_ID().equal(any(3, 4)))
|
||||
.and(TBook_ID().notEqual(create().select(val(1))))
|
||||
.and(TBook_ID().notEqualAll(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().notEqualAll(1, 4, 4))
|
||||
.and(TBook_ID().notEqualAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().notEqualAny(1, 4, 4))
|
||||
.and(TBook_ID().notEqual(all(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().notEqual(all(1, 4, 4)))
|
||||
.and(TBook_ID().notEqual(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().notEqual(any(1, 4, 4)))
|
||||
.and(TBook_ID().greaterOrEqual(create().select(val(1))))
|
||||
.and(TBook_ID().greaterOrEqualAll(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2))))
|
||||
.and(TBook_ID().greaterOrEqualAll(1, 2))
|
||||
.and(TBook_ID().greaterOrEqualAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().greaterOrEqualAny(1, 4))
|
||||
.and(TBook_ID().greaterOrEqual(all(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2)))))
|
||||
.and(TBook_ID().greaterOrEqual(all(1, 2)))
|
||||
.and(TBook_ID().greaterOrEqual(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().greaterOrEqual(any(1, 4)))
|
||||
.and(TBook_ID().greaterThan(create().select(val(1))))
|
||||
.and(TBook_ID().greaterThanAll(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2))))
|
||||
.and(TBook_ID().greaterThanAll(1, 2))
|
||||
.and(TBook_ID().greaterThanAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().greaterThanAny(1, 4))
|
||||
.and(TBook_ID().greaterThan(all(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 2)))))
|
||||
.and(TBook_ID().greaterThan(all(1, 2)))
|
||||
.and(TBook_ID().greaterThan(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().greaterThan(any(1, 4)))
|
||||
.and(TBook_ID().lessOrEqual(create().select(val(3))))
|
||||
.and(TBook_ID().lessOrEqualAll(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(3, 4))))
|
||||
.and(TBook_ID().lessOrEqualAll(3, 4))
|
||||
.and(TBook_ID().lessOrEqualAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().lessOrEqualAny(1, 4))
|
||||
.and(TBook_ID().lessOrEqual(all(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(3, 4)))))
|
||||
.and(TBook_ID().lessOrEqual(all(3, 4)))
|
||||
.and(TBook_ID().lessOrEqual(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().lessOrEqual(any(1, 4)))
|
||||
.and(TBook_ID().lessThan(create().select(val(4))))
|
||||
.and(TBook_ID().lessThanAll(create().select(val(4))))
|
||||
.and(TBook_ID().lessThanAll(4, 5))
|
||||
.and(TBook_ID().lessThanAny(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4))))
|
||||
.and(TBook_ID().lessThanAny(1, 4))
|
||||
.and(TBook_ID().lessThan(all(create().select(val(4)))))
|
||||
.and(TBook_ID().lessThan(all(4, 5)))
|
||||
.and(TBook_ID().lessThan(any(create().select(TBook_ID()).from(TBook()).where(TBook_ID().in(1, 4)))))
|
||||
.and(TBook_ID().lessThan(any(1, 4)))
|
||||
.fetch(TBook_ID()));
|
||||
|
||||
break;
|
||||
|
||||
@ -77,7 +77,8 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* The name is any of these:
|
||||
* <ul>
|
||||
* <li>The formal name of the field, if it is a <i>physical table/view field</i></li>
|
||||
* <li>The formal name of the field, if it is a <i>physical table/view
|
||||
* field</i></li>
|
||||
* <li>The alias of an <i>aliased field</i></li>
|
||||
* <li>A generated / unspecified value for any other <i>expression</i></li>
|
||||
* <li>The name of a parameter if it is a named {@link Param}</li>
|
||||
@ -310,8 +311,7 @@ public interface Field<T> extends QueryPart {
|
||||
/**
|
||||
* Negate this field to get its negative value.
|
||||
* <p>
|
||||
* This renders the same on all dialects:
|
||||
* <code><pre>-[this]</pre></code>
|
||||
* This renders the same on all dialects: <code><pre>-[this]</pre></code>
|
||||
*/
|
||||
@Support
|
||||
Field<T> neg();
|
||||
@ -464,9 +464,8 @@ public interface Field<T> extends QueryPart {
|
||||
* An arithmetic expression getting the modulo of this divided by value
|
||||
* <p>
|
||||
* This renders the modulo operation where available:
|
||||
* <code><pre>[this] % [value]</pre></code>
|
||||
* ... or the modulo function elsewhere:
|
||||
* <code><pre>mod([this], [value])</pre></code>
|
||||
* <code><pre>[this] % [value]</pre></code> ... or the modulo function
|
||||
* elsewhere: <code><pre>mod([this], [value])</pre></code>
|
||||
*/
|
||||
@Support
|
||||
Field<T> mod(Number value);
|
||||
@ -475,9 +474,8 @@ public interface Field<T> extends QueryPart {
|
||||
* An arithmetic expression getting the modulo of this divided by value
|
||||
* <p>
|
||||
* This renders the modulo operation where available:
|
||||
* <code><pre>[this] % [value]</pre></code>
|
||||
* ... or the modulo function elsewhere:
|
||||
* <code><pre>mod([this], [value])</pre></code>
|
||||
* <code><pre>[this] % [value]</pre></code> ... or the modulo function
|
||||
* elsewhere: <code><pre>mod([this], [value])</pre></code>
|
||||
*/
|
||||
@Support
|
||||
Field<T> mod(Field<? extends Number> value);
|
||||
@ -654,8 +652,8 @@ public interface Field<T> extends QueryPart {
|
||||
* <td><code>[search] REGEXP [pattern]</code></td>
|
||||
* <td>POSIX</td>
|
||||
* <td><a href=
|
||||
* "http://dev.mysql.com/doc/refman/5.6/en/regexp.html">http://dev.mysql.com/doc/refman/5.6/en/regexp.html</a
|
||||
* ></td>
|
||||
* "http://dev.mysql.com/doc/refman/5.6/en/regexp.html">http://dev
|
||||
* .mysql.com/doc/refman/5.6/en/regexp.html</a ></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link SQLDialect#ORACLE}</td>
|
||||
@ -1103,8 +1101,7 @@ public interface Field<T> extends QueryPart {
|
||||
/**
|
||||
* Create a condition to check this field against some bounds
|
||||
* <p>
|
||||
* This is the same as calling
|
||||
* <code>between(minValue).and(maxValue)</code>
|
||||
* This is the same as calling <code>between(minValue).and(maxValue)</code>
|
||||
* <p>
|
||||
* SQL: <code>this between minValue and maxValue</code>
|
||||
*/
|
||||
@ -1114,8 +1111,7 @@ public interface Field<T> extends QueryPart {
|
||||
/**
|
||||
* Create a condition to check this field against some bounds
|
||||
* <p>
|
||||
* This is the same as calling
|
||||
* <code>between(minValue).and(maxValue)</code>
|
||||
* This is the same as calling <code>between(minValue).and(maxValue)</code>
|
||||
* <p>
|
||||
* SQL: <code>this between minValue and maxValue</code>
|
||||
*/
|
||||
@ -1300,6 +1296,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition equal(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this = [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition equal(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this = value</code>
|
||||
* <p>
|
||||
@ -1328,6 +1337,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition eq(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this = [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition eq(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this != value</code>
|
||||
* <p>
|
||||
@ -1350,6 +1372,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition notEqual(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this != [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition notEqual(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this != value</code>
|
||||
* <p>
|
||||
@ -1378,6 +1413,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition ne(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this != [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition ne(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this < value</code>
|
||||
*/
|
||||
@ -1396,6 +1444,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition lessThan(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this < [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessThan(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this < value</code>
|
||||
*
|
||||
@ -1420,6 +1481,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition lt(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this < [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lt(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this <= value</code>
|
||||
*/
|
||||
@ -1438,6 +1512,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition lessOrEqual(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this <= [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessOrEqual(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this <= value</code>
|
||||
*
|
||||
@ -1462,6 +1549,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition le(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this <= [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition le(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this > value</code>
|
||||
*/
|
||||
@ -1480,6 +1580,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition greaterThan(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this > [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterThan(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this > value</code>
|
||||
*
|
||||
@ -1504,6 +1617,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition gt(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this > [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition gt(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this >= value</code>
|
||||
*/
|
||||
@ -1522,6 +1648,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition greaterOrEqual(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this >= [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterOrEqual(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* <code>this >= value</code>
|
||||
*
|
||||
@ -1546,6 +1685,19 @@ public interface Field<T> extends QueryPart {
|
||||
@Support
|
||||
Condition ge(Select<?> query);
|
||||
|
||||
/**
|
||||
* <code>this >= [quantifier] (Select<?> ...)</code>
|
||||
*
|
||||
* @see Factory#all(Field)
|
||||
* @see Factory#all(Select)
|
||||
* @see Factory#all(Object...)
|
||||
* @see Factory#any(Field)
|
||||
* @see Factory#any(Select)
|
||||
* @see Factory#any(Object...)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition ge(QuantifiedSelect<?> query);
|
||||
|
||||
/**
|
||||
* Create a condition to check this field against known string literals for
|
||||
* <code>true</code>
|
||||
@ -1596,7 +1748,11 @@ public interface Field<T> extends QueryPart {
|
||||
|
||||
/**
|
||||
* <code>this = any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition equalAny(Select<?> query);
|
||||
|
||||
@ -1605,7 +1761,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition equalAny(T... array);
|
||||
|
||||
@ -1614,13 +1774,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, CUBRID, HSQLDB, POSTGRES })
|
||||
Condition equalAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this = all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition equalAll(Select<?> query);
|
||||
|
||||
@ -1629,7 +1797,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition equalAll(T... array);
|
||||
|
||||
@ -1638,13 +1810,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition equalAll(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this != any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition notEqualAny(Select<?> query);
|
||||
|
||||
@ -1653,7 +1833,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition notEqualAny(T... array);
|
||||
|
||||
@ -1662,13 +1846,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition notEqualAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this != all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition notEqualAll(Select<?> query);
|
||||
|
||||
@ -1677,7 +1869,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition notEqualAll(T... array);
|
||||
|
||||
@ -1686,13 +1882,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition notEqualAll(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this < any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessThanAny(Select<?> query);
|
||||
|
||||
@ -1701,7 +1905,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessThanAny(T... array);
|
||||
|
||||
@ -1710,13 +1918,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition lessThanAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this < all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessThanAll(Select<?> query);
|
||||
|
||||
@ -1725,7 +1941,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessThanAll(T... array);
|
||||
|
||||
@ -1734,13 +1954,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition lessThanAll(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this <= any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessOrEqualAny(Select<?> query);
|
||||
|
||||
@ -1749,7 +1977,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessOrEqualAny(T... array);
|
||||
|
||||
@ -1758,13 +1990,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition lessOrEqualAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this <= all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessOrEqualAll(Select<?> query);
|
||||
|
||||
@ -1773,7 +2013,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition lessOrEqualAll(T... array);
|
||||
|
||||
@ -1782,13 +2026,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition lessOrEqualAll(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this > any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterThanAny(Select<?> query);
|
||||
|
||||
@ -1797,7 +2049,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterThanAny(T... array);
|
||||
|
||||
@ -1806,13 +2062,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition greaterThanAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this > all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterThanAll(Select<?> query);
|
||||
|
||||
@ -1821,7 +2085,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterThanAll(T... array);
|
||||
|
||||
@ -1830,13 +2098,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition greaterThanAll(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this >= any (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterOrEqualAny(Select<?> query);
|
||||
|
||||
@ -1845,7 +2121,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterOrEqualAny(T... array);
|
||||
|
||||
@ -1854,13 +2134,21 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#any(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition greaterOrEqualAny(Field<T[]> array);
|
||||
|
||||
/**
|
||||
* <code>this >= all (Select<?> ...)</code>
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Select)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterOrEqualAll(Select<?> query);
|
||||
|
||||
@ -1869,7 +2157,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Object...)} instead
|
||||
* for quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
Condition greaterOrEqualAll(T... array);
|
||||
|
||||
@ -1878,7 +2170,11 @@ public interface Field<T> extends QueryPart {
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @deprecated - 2.7.0 [#1697] - Use {@link Factory#all(Field)} instead for
|
||||
* quantified comparison predicates
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
Condition greaterOrEqualAll(Field<T[]> array);
|
||||
|
||||
|
||||
53
jOOQ/src/main/java/org/jooq/QuantifiedSelect.java
Normal file
53
jOOQ/src/main/java/org/jooq/QuantifiedSelect.java
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* A participant of a quantified comparison predicate
|
||||
* <p>
|
||||
* A <code>QuantifiedSelect</code> models the right hand side of a quantified
|
||||
* comparison predicate. Examples of such predicates:
|
||||
* <ul>
|
||||
* <li><code>ANY (SELECT 1 FROM DUAL)</code></li>
|
||||
* <li><code>ALL (SELECT 1 FROM DUAL)</code></li>
|
||||
* </ul>
|
||||
* These predicates can be used exclusively with methods, such as {@link Field}
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface QuantifiedSelect<R extends Record> extends QueryPart {
|
||||
|
||||
}
|
||||
@ -39,6 +39,8 @@ import static org.jooq.impl.ExpressionOperator.ADD;
|
||||
import static org.jooq.impl.ExpressionOperator.DIVIDE;
|
||||
import static org.jooq.impl.ExpressionOperator.MULTIPLY;
|
||||
import static org.jooq.impl.ExpressionOperator.SUBTRACT;
|
||||
import static org.jooq.impl.Factory.all;
|
||||
import static org.jooq.impl.Factory.any;
|
||||
import static org.jooq.impl.Factory.falseCondition;
|
||||
import static org.jooq.impl.Factory.inline;
|
||||
import static org.jooq.impl.Factory.nullSafe;
|
||||
@ -66,6 +68,7 @@ import org.jooq.Configuration;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.DatePart;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.QuantifiedSelect;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.SortField;
|
||||
@ -669,6 +672,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return equal(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition eq(QuantifiedSelect<?> query) {
|
||||
return equal(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition ne(T value) {
|
||||
return notEqual(value);
|
||||
@ -684,6 +692,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return notEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition ne(QuantifiedSelect<?> query) {
|
||||
return notEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lt(T value) {
|
||||
return lessThan(value);
|
||||
@ -699,6 +712,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return lessThan(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lt(QuantifiedSelect<?> query) {
|
||||
return lessThan(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition le(T value) {
|
||||
return lessOrEqual(value);
|
||||
@ -714,6 +732,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return lessOrEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition le(QuantifiedSelect<?> query) {
|
||||
return lessOrEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition gt(T value) {
|
||||
return greaterThan(value);
|
||||
@ -729,6 +752,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return greaterThan(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition gt(QuantifiedSelect<?> query) {
|
||||
return greaterThan(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition ge(T value) {
|
||||
return greaterOrEqual(value);
|
||||
@ -744,6 +772,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return greaterOrEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition ge(QuantifiedSelect<?> query) {
|
||||
return greaterOrEqual(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equal(T value) {
|
||||
return equal(val(value, this));
|
||||
@ -769,34 +802,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.EQUALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equal(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.EQUALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.EQUALS_ANY);
|
||||
return equal(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAny(T... array) {
|
||||
return equalAny(val(array));
|
||||
return equal(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.EQUALS_ANY);
|
||||
return equal(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.EQUALS_ALL);
|
||||
return equal(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAll(T... array) {
|
||||
return equalAll(val(array));
|
||||
return equal(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition equalAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.EQUALS_ALL);
|
||||
return equal(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -824,34 +862,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.NOT_EQUALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqual(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.NOT_EQUALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.NOT_EQUALS_ANY);
|
||||
return notEqual(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAny(T... array) {
|
||||
return notEqualAny(val(array));
|
||||
return notEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.NOT_EQUALS_ANY);
|
||||
return notEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.NOT_EQUALS_ALL);
|
||||
return notEqual(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAll(T... array) {
|
||||
return notEqualAll(val(array));
|
||||
return notEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition notEqualAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.NOT_EQUALS_ALL);
|
||||
return notEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -869,34 +912,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThan(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.LESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS_THAN_ANY);
|
||||
return lessThan(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAny(T... array) {
|
||||
return lessThanAny(val(array));
|
||||
return lessThan(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.LESS_THAN_ANY);
|
||||
return lessThan(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS_THAN_ALL);
|
||||
return lessThan(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAll(T... array) {
|
||||
return lessThanAll(val(array));
|
||||
return lessThan(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessThanAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.LESS_THAN_ALL);
|
||||
return lessThan(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -914,34 +962,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS_OR_EQUAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqual(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.LESS_OR_EQUAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS_OR_EQUAL_ANY);
|
||||
return lessOrEqual(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAny(T... array) {
|
||||
return lessOrEqualAny(val(array));
|
||||
return lessOrEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.LESS_OR_EQUAL_ANY);
|
||||
return lessOrEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.LESS_OR_EQUAL_ALL);
|
||||
return lessOrEqual(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAll(T... array) {
|
||||
return lessOrEqualAll(val(array));
|
||||
return lessOrEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition lessOrEqualAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.LESS_OR_EQUAL_ALL);
|
||||
return lessOrEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -959,34 +1012,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThan(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.GREATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_THAN_ANY);
|
||||
return greaterThan(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAny(T... array) {
|
||||
return greaterThanAny(val(array));
|
||||
return greaterThan(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.GREATER_THAN_ANY);
|
||||
return greaterThan(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_THAN_ALL);
|
||||
return greaterThan(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAll(T... array) {
|
||||
return greaterThanAll(val(array));
|
||||
return greaterThan(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterThanAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.GREATER_THAN_ALL);
|
||||
return greaterThan(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1004,34 +1062,39 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_OR_EQUAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqual(QuantifiedSelect<?> query) {
|
||||
return new QuantifiedComparisonCondition(query, this, Comparator.GREATER_OR_EQUAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAny(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_OR_EQUAL_ANY);
|
||||
return greaterOrEqual(any(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAny(T... array) {
|
||||
return greaterOrEqualAny(val(array));
|
||||
return greaterOrEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAny(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.GREATER_OR_EQUAL_ANY);
|
||||
return greaterOrEqual(any(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAll(Select<?> query) {
|
||||
return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_OR_EQUAL_ALL);
|
||||
return greaterOrEqual(all(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAll(T... array) {
|
||||
return greaterOrEqualAll(val(array));
|
||||
return greaterOrEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition greaterOrEqualAll(Field<T[]> array) {
|
||||
return new ArrayAsSubqueryCondition<T>(nullSafe(array), this, SubQueryOperator.GREATER_OR_EQUAL_ALL);
|
||||
return greaterOrEqual(all(array));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -73,6 +73,7 @@ import org.jooq.GroupConcatOrderByStep;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.OrderedAggregateFunction;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.QuantifiedSelect;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
@ -104,6 +105,118 @@ import org.jooq.types.DayToSecond;
|
||||
*/
|
||||
public class Factory {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Quantified comparison predicate expressions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create an <code>ALL</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
public static <R extends Record> QuantifiedSelect<R> all(Select<R> select) {
|
||||
return new QuantifiedSelectImpl<R>(Quantifier.ALL, select);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>ALL</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
public static <T> QuantifiedSelect<Record> all(T... array) {
|
||||
return all(val(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>ALL</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
public static <T> QuantifiedSelect<Record> all(Field<T[]> array) {
|
||||
return new QuantifiedSelectImpl<Record>(Quantifier.ALL, array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>ANY</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
public static <R extends Record> QuantifiedSelect<R> any(Select<R> select) {
|
||||
return new QuantifiedSelectImpl<R>(Quantifier.ANY, select);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>ANY</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE })
|
||||
public static <T> QuantifiedSelect<Record> any(T... array) {
|
||||
return any(val(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>ANY</code> quantified select to be used in quantified
|
||||
* comparison predicate expressions.
|
||||
* <p>
|
||||
* This is natively supported by {@link SQLDialect#POSTGRES}. Other dialects
|
||||
* will render a subselect unnesting the array.
|
||||
*
|
||||
* @see Field#equal(QuantifiedSelect)
|
||||
* @see Field#notEqual(QuantifiedSelect)
|
||||
* @see Field#greaterThan(QuantifiedSelect)
|
||||
* @see Field#greaterOrEqual(QuantifiedSelect)
|
||||
* @see Field#lessThan(QuantifiedSelect)
|
||||
* @see Field#lessOrEqual(QuantifiedSelect)
|
||||
*/
|
||||
@Support({ H2, HSQLDB, POSTGRES })
|
||||
public static <T> QuantifiedSelect<Record> any(Field<T[]> array) {
|
||||
return new QuantifiedSelectImpl<Record>(Quantifier.ANY, array);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Conversion of objects into tables
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -1,105 +1,76 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Factory.table;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.RenderContext;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class ArrayAsSubqueryCondition<T> extends AbstractCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -1074020279396496305L;
|
||||
|
||||
private final Field<T[]> array;
|
||||
private final Field<?> field;
|
||||
private final SubQueryOperator operator;
|
||||
|
||||
ArrayAsSubqueryCondition(Field<T[]> array, Field<T> field, SubQueryOperator operator) {
|
||||
this.array = array;
|
||||
this.field = field;
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
context.sql(field)
|
||||
.sql(" ")
|
||||
.keyword(operator.toSQL())
|
||||
.sql(" (")
|
||||
.formatIndentStart()
|
||||
.formatNewLine()
|
||||
.sql(array(context))
|
||||
.formatIndentEnd()
|
||||
.formatNewLine()
|
||||
.sql(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
context.bind(field).bind(array(context));
|
||||
}
|
||||
|
||||
private final QueryPart array(Configuration context) {
|
||||
switch (context.getDialect()) {
|
||||
|
||||
// [#869] Postgres supports this syntax natively
|
||||
case POSTGRES: {
|
||||
return array;
|
||||
}
|
||||
|
||||
// [#869] H2 and HSQLDB can simulate this syntax by unnesting
|
||||
// the array in a subselect
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
|
||||
// [#1048] All other dialects simulate unnesting of arrays using
|
||||
// UNION ALL-connected subselects
|
||||
default: {
|
||||
return create(context).select().from(table(array));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Comparator;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.QuantifiedSelect;
|
||||
import org.jooq.RenderContext;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class QuantifiedComparisonCondition extends AbstractCondition {
|
||||
|
||||
private static final long serialVersionUID = -402776705884329740L;
|
||||
|
||||
private final QuantifiedSelect<?> query;
|
||||
private final Field<?> field;
|
||||
private final Comparator comparator;
|
||||
|
||||
QuantifiedComparisonCondition(QuantifiedSelect<?> query, Field<?> field, Comparator comparator) {
|
||||
this.query = query;
|
||||
this.field = field;
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
context.sql(field)
|
||||
.sql(" ")
|
||||
.keyword(comparator.toSQL())
|
||||
.sql(" ")
|
||||
.sql(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
context.bind(field).bind(query);
|
||||
}
|
||||
}
|
||||
142
jOOQ/src/main/java/org/jooq/impl/QuantifiedSelectImpl.java
Normal file
142
jOOQ/src/main/java/org/jooq/impl/QuantifiedSelectImpl.java
Normal file
@ -0,0 +1,142 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Factory.table;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.QuantifiedSelect;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class QuantifiedSelectImpl<R extends Record> extends AbstractQueryPart implements QuantifiedSelect<R> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -1224570388944748450L;
|
||||
|
||||
private final Quantifier quantifier;
|
||||
private final Select<R> query;
|
||||
private final Field<? extends Object[]> array;
|
||||
|
||||
QuantifiedSelectImpl(Quantifier quantifier, Select<R> query) {
|
||||
this.quantifier = quantifier;
|
||||
this.query = query;
|
||||
this.array = null;
|
||||
}
|
||||
|
||||
QuantifiedSelectImpl(Quantifier quantifier, Field<? extends Object[]> array) {
|
||||
this.quantifier = quantifier;
|
||||
this.query = null;
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
|
||||
// If this is already a subquery, proceed
|
||||
if (context.subquery()) {
|
||||
context.keyword(quantifier.toSQL())
|
||||
.sql(" (")
|
||||
.formatIndentStart()
|
||||
.formatNewLine()
|
||||
.sql(part(context))
|
||||
.formatIndentEnd()
|
||||
.formatNewLine()
|
||||
.sql(")");
|
||||
}
|
||||
else {
|
||||
context.keyword(quantifier.toSQL())
|
||||
.sql(" (")
|
||||
.subquery(true)
|
||||
.formatIndentStart()
|
||||
.formatNewLine()
|
||||
.sql(part(context))
|
||||
.formatIndentEnd()
|
||||
.formatNewLine()
|
||||
.subquery(false)
|
||||
.sql(")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
|
||||
// If this is already a subquery, proceed
|
||||
if (context.subquery()) {
|
||||
context.bind(part(context));
|
||||
}
|
||||
else {
|
||||
context.subquery(true)
|
||||
.bind(part(context))
|
||||
.subquery(false);
|
||||
}
|
||||
}
|
||||
|
||||
private final QueryPart part(Configuration context) {
|
||||
if (query != null) {
|
||||
return query;
|
||||
}
|
||||
else {
|
||||
switch (context.getDialect()) {
|
||||
|
||||
// [#869] Postgres supports this syntax natively
|
||||
case POSTGRES: {
|
||||
return array;
|
||||
}
|
||||
|
||||
// [#869] H2 and HSQLDB can simulate this syntax by unnesting
|
||||
// the array in a subselect
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
|
||||
// [#1048] All other dialects simulate unnesting of arrays using
|
||||
// UNION ALL-connected subselects
|
||||
default: {
|
||||
return create(context).select().from(table(array));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
jOOQ/src/main/java/org/jooq/impl/Quantifier.java
Normal file
67
jOOQ/src/main/java/org/jooq/impl/Quantifier.java
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
/**
|
||||
* A quantifier used for quantified comparison predicates
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
enum Quantifier {
|
||||
|
||||
/**
|
||||
* The <code>ANY</code> quantifier
|
||||
*/
|
||||
ANY("any"),
|
||||
|
||||
/**
|
||||
* The <code>ALL</code> quantifier
|
||||
*/
|
||||
ALL("all"),
|
||||
|
||||
;
|
||||
|
||||
private final String sql;
|
||||
|
||||
private Quantifier(String sql) {
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
public String toSQL() {
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
@ -46,23 +46,13 @@ enum SubQueryOperator {
|
||||
IN("in"),
|
||||
NOT_IN("not in"),
|
||||
EQUALS("="),
|
||||
EQUALS_ANY("= any"),
|
||||
EQUALS_ALL("= all"),
|
||||
NOT_EQUALS("<>"),
|
||||
NOT_EQUALS_ANY("<> any"),
|
||||
NOT_EQUALS_ALL("<> all"),
|
||||
LESS("<"),
|
||||
LESS_THAN_ANY("< any"),
|
||||
LESS_THAN_ALL("< all"),
|
||||
LESS_OR_EQUAL("<="),
|
||||
LESS_OR_EQUAL_ANY("<= any"),
|
||||
LESS_OR_EQUAL_ALL("<= all"),
|
||||
GREATER(">"),
|
||||
GREATER_THAN_ANY("> any"),
|
||||
GREATER_THAN_ALL("> all"),
|
||||
GREATER_OR_EQUAL(">="),
|
||||
GREATER_OR_EQUAL_ANY(">= any"),
|
||||
GREATER_OR_EQUAL_ALL(">= all"), ;
|
||||
|
||||
;
|
||||
|
||||
private final String sql;
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ package org.jooq.test;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.jooq.JoinType.LEFT_OUTER_JOIN;
|
||||
import static org.jooq.impl.Factory.any;
|
||||
import static org.jooq.impl.Factory.avg;
|
||||
import static org.jooq.impl.Factory.condition;
|
||||
import static org.jooq.impl.Factory.count;
|
||||
@ -2357,7 +2358,7 @@ public class BasicTest {
|
||||
q2.addFrom(TABLE2);
|
||||
|
||||
q2.addSelect(FIELD_ID2);
|
||||
q1.addConditions(FIELD_ID1.greaterThanAny(q2));
|
||||
q1.addConditions(FIELD_ID1.greaterThan(any(q2)));
|
||||
|
||||
assertEquals("select \"TABLE1\".\"ID1\", \"TABLE1\".\"NAME1\", \"TABLE1\".\"DATE1\" from \"TABLE1\" where \"TABLE1\".\"ID1\" > any (select \"TABLE2\".\"ID2\" from \"TABLE2\")", r_refI().render(q1));
|
||||
assertEquals("select \"TABLE1\".\"ID1\", \"TABLE1\".\"NAME1\", \"TABLE1\".\"DATE1\" from \"TABLE1\" where \"TABLE1\".\"ID1\" > any (select \"TABLE2\".\"ID2\" from \"TABLE2\")", r_ref().render(q1));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user