use of org.jooq.Configuration 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.Configuration in project jOOQ by jOOQ.
the class Mock method result.
/**
* Wrap a record in a result.
*/
static final Result<?> result(Record data) {
Configuration configuration = data instanceof AttachableInternal ? ((AttachableInternal) data).configuration() : new DefaultConfiguration();
Result<Record> result = using(configuration).newResult(data.fields());
result.add(data);
return result;
}
use of org.jooq.Configuration in project spring-boot by spring-projects.
the class JooqExceptionTranslatorTests method exceptionTranslation.
@Test
public void exceptionTranslation() {
ExecuteContext context = mock(ExecuteContext.class);
Configuration configuration = mock(Configuration.class);
given(context.configuration()).willReturn(configuration);
given(configuration.dialect()).willReturn(this.dialect);
given(context.sqlException()).willReturn(this.sqlException);
this.exceptionTranslator.exception(context);
ArgumentCaptor<RuntimeException> captor = ArgumentCaptor.forClass(RuntimeException.class);
verify(context).exception(captor.capture());
assertThat(captor.getValue()).isInstanceOf(BadSqlGrammarException.class);
}
use of org.jooq.Configuration in project vertx-zero by silentbalanceyh.
the class JooqInfix method initInternal.
private static void initInternal(final Vertx vertx, final String name) {
vertxRef = vertx;
Fn.pool(CONFIGS, name, () -> Infix.init(Plugins.Infix.JOOQ, (config) -> {
// Initialized client
final Configuration configuration = new DefaultConfiguration();
configuration.set(SQLDialect.MYSQL_8_0);
final ConnectionProvider provider = new DefaultConnectionProvider(HikariCpPool.getConnection(config.getJsonObject("provider")));
// Initialized default configuration
configuration.set(provider);
return configuration;
}, JooqInfix.class));
}
use of org.jooq.Configuration in project spring-boot by spring-projects.
the class JooqExceptionTranslatorTests method whenExceptionCannotBeTranslatedThenExecuteContextExceptionIsNotCalled.
@Test
void whenExceptionCannotBeTranslatedThenExecuteContextExceptionIsNotCalled() {
ExecuteContext context = mock(ExecuteContext.class);
Configuration configuration = mock(Configuration.class);
given(context.configuration()).willReturn(configuration);
given(configuration.dialect()).willReturn(SQLDialect.POSTGRES);
given(context.sqlException()).willReturn(new SQLException(null, null, 123456789));
this.exceptionTranslator.exception(context);
then(context).should(never()).exception(any());
}
Aggregations