use of org.jooq.Condition in project jOOQ by jOOQ.
the class RowSubqueryCondition method delegate.
private final QueryPartInternal delegate(Context<?> ctx) {
final Configuration configuration = ctx.configuration();
final RenderContext render = ctx instanceof RenderContext ? (RenderContext) ctx : null;
SQLDialect family = configuration.dialect().family();
// [#3505] TODO: Emulate this where it is not supported
if (rightQuantified != null) {
return new Native();
} else // predicates with row value expressions and subqueries:
if (asList(H2, HSQLDB, MARIADB, MYSQL, POSTGRES).contains(family)) {
return new Native();
} else // [#2395] All other configurations have to be emulated
{
String table = render == null ? "t" : render.nextAlias();
List<String> names = new ArrayList<String>();
for (int i = 0; i < left.size(); i++) {
names.add(table + "_" + i);
}
Field<?>[] fields = new Field[names.size()];
for (int i = 0; i < fields.length; i++) {
fields[i] = field(name(table, names.get(i)));
}
Condition condition;
switch(comparator) {
case GREATER:
condition = ((RowN) left).gt(row(fields));
break;
case GREATER_OR_EQUAL:
condition = ((RowN) left).ge(row(fields));
break;
case LESS:
condition = ((RowN) left).lt(row(fields));
break;
case LESS_OR_EQUAL:
condition = ((RowN) left).le(row(fields));
break;
case IN:
case EQUALS:
case NOT_IN:
case NOT_EQUALS:
default:
condition = ((RowN) left).eq(row(fields));
break;
}
Select<Record> subselect = select().from(right.asTable(table, names.toArray(EMPTY_STRING))).where(condition);
switch(comparator) {
case NOT_IN:
case NOT_EQUALS:
return (QueryPartInternal) notExists(subselect);
default:
return (QueryPartInternal) exists(subselect);
}
}
}
use of org.jooq.Condition in project torodb by torodb.
the class AbstractMetaDataWriteInterface method writeMetaInfo.
@Override
public String writeMetaInfo(DSLContext dsl, MetaInfoKey key, String newValue) {
Condition c = kvTable.KEY.eq(key.getKeyName());
Optional<String> oldValue = dsl.select(kvTable.VALUE).from(kvTable).where(c).fetchOptional().map(Record1::value1);
if (oldValue.isPresent()) {
int updatedRows = dsl.update(kvTable).set(kvTable.KEY, key.getKeyName()).set(kvTable.VALUE, newValue).where(c).execute();
assert updatedRows == 1;
} else {
int newRows = dsl.insertInto(kvTable, kvTable.KEY, kvTable.VALUE).values(key.getKeyName(), newValue).execute();
assert newRows == 1;
}
return oldValue.orElse(null);
}
use of org.jooq.Condition in project waltz by khartec.
the class PhysicalSpecificationIdSelectorFactory method mkForLogicalFlow.
private Select<Record1<Long>> mkForLogicalFlow(IdSelectionOptions options) {
ensureScopeIsExact(options);
long logicalFlowId = options.entityReference().id();
Condition matchOnLogicalFlowId = PHYSICAL_FLOW.LOGICAL_FLOW_ID.eq(logicalFlowId);
return selectViaPhysicalFlowJoin(matchOnLogicalFlowId);
}
use of org.jooq.Condition in project waltz by khartec.
the class PhysicalSpecificationIdSelectorFactory method mkForPhysicalFlow.
private Select<Record1<Long>> mkForPhysicalFlow(IdSelectionOptions options) {
ensureScopeIsExact(options);
long physicalFlowId = options.entityReference().id();
Condition matchOnPhysFlowId = PHYSICAL_FLOW.ID.eq(physicalFlowId);
return selectViaPhysicalFlowJoin(matchOnPhysFlowId);
}
use of org.jooq.Condition in project waltz by khartec.
the class PhysicalSpecificationIdSelectorFactory method mkForFlowDiagram.
private Select<Record1<Long>> mkForFlowDiagram(IdSelectionOptions options) {
ensureScopeIsExact(options);
Select<Record1<Long>> flowSelector = physicalFlowIdSelectorFactory.apply(options);
Condition condition = PHYSICAL_FLOW.ID.in(flowSelector);
return selectViaPhysicalFlowJoin(condition);
}
Aggregations