[jOOQ/jOOQ#12425] Move EXISTS predicate to API generator
Fix a regression where separator comments and other meta data was no longer generated when interleaving operators with functions
This commit is contained in:
parent
404eec8004
commit
86ef0311e0
@ -740,6 +740,10 @@ extends
|
||||
@Support
|
||||
Condition isNotDistinctFrom(Field<T> arg2);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Numeric functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The <code>BIT_AND</code> operator.
|
||||
*
|
||||
|
||||
@ -375,6 +375,10 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
|
||||
return new IsNotDistinctFrom(this, nullSafe(arg2, getDataType()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Numeric functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public final Field<T> bitAnd(T arg2) {
|
||||
|
||||
@ -14525,28 +14525,6 @@ public class DSL {
|
||||
return CombinedCondition.of(operator, conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an exists condition.
|
||||
* <p>
|
||||
* <code>EXISTS ([query])</code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Condition exists(Select<?> query) {
|
||||
return new ExistsCondition(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a not exists condition.
|
||||
* <p>
|
||||
* <code>NOT EXISTS ([query])</code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Condition notExists(Select<?> query) {
|
||||
return not(exists(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert a boolean value.
|
||||
* <p>
|
||||
@ -15656,6 +15634,28 @@ public class DSL {
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Boolean functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The <code>EXISTS</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Condition exists(Select<?> query) {
|
||||
return new Exists(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>NOT EXISTS</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static Condition notExists(Select<?> query) {
|
||||
return not(exists(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>NOT</code> function.
|
||||
*/
|
||||
|
||||
@ -35,31 +35,54 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.CONDITION;
|
||||
import static org.jooq.Clause.CONDITION_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_EXISTS;
|
||||
import static org.jooq.impl.Tools.visitSubquery;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.impl.Tools.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.conf.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Select;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>EXISTS</code> statement.
|
||||
*/
|
||||
final class ExistsCondition extends AbstractCondition {
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
final class Exists
|
||||
extends
|
||||
AbstractCondition
|
||||
{
|
||||
|
||||
private static final Clause[] CLAUSES_EXISTS = { CONDITION, CONDITION_EXISTS };
|
||||
private final Select<?> query;
|
||||
|
||||
private final Select<?> query;
|
||||
Exists(
|
||||
Select<?> query
|
||||
) {
|
||||
|
||||
ExistsCondition(Select<?> query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES_EXISTS = { CONDITION, CONDITION_EXISTS };
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
@ -82,8 +105,20 @@ final class ExistsCondition extends AbstractCondition {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES_EXISTS;
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Exists) {
|
||||
return
|
||||
StringUtils.equals(query, ((Exists) that).query)
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user