use of org.jooq.impl.DefaultRenderContext.Rendered in project jOOQ by jOOQ.
the class AbstractQuery method getSQL0.
private final Rendered getSQL0(ExecuteContext ctx) {
Rendered result;
DefaultRenderContext render;
Configuration c = configurationOrThrow();
// [#6474] [#6929] Can this be communicated in a leaner way?
if (ctx.type() == DDL) {
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
render = new DefaultRenderContext(c);
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
} else if (executePreparedStatements(configuration().settings())) {
try {
render = new DefaultRenderContext(c);
render.data(DATA_COUNT_BIND_VALUES, true);
result = new Rendered(render.visit(this).render(), render.bindValues(), render.skipUpdateCounts());
} catch (DefaultRenderContext.ForceInlineSignal e) {
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
render = new DefaultRenderContext(c);
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
}
} else {
render = new DefaultRenderContext(c);
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
}
return result;
}
use of org.jooq.impl.DefaultRenderContext.Rendered in project jOOQ by jOOQ.
the class ParsingConnection method translate.
static final Rendered translate(Configuration configuration, String sql, Param<?>... bindValues) {
log.debug("Translating from", sql);
Rendered result = null;
Supplier<CacheValue> miss = () -> {
log.debug("Translation cache miss", sql);
return new CacheValue(configuration, sql, bindValues);
};
Settings settings = configuration.settings();
if (CACHE_PARSING_CONNECTION.category.predicate.test(settings) && bindValues.length > 0) {
switch(getParamType(settings)) {
case INLINED:
case NAMED_OR_INLINED:
result = miss.get().rendered(bindValues);
break;
}
}
if (result == null)
result = Cache.run(configuration, miss, CACHE_PARSING_CONNECTION, () -> Cache.key(sql, map(nonNull(bindValues), f -> f.getDataType()))).rendered(bindValues);
log.debug("Translating to", result.sql);
return result;
}
Aggregations