[jOOQ/jOOQ#15504] Query::isExecutable should be checked in the R2DBC, allowing no-ops for non-executable queries
This commit is contained in:
parent
178e9add3f
commit
bfc88406bb
@ -429,33 +429,42 @@ final class R2DBC {
|
||||
@Override
|
||||
final void onNext0(Connection c) {
|
||||
try {
|
||||
Rendered rendered = rendered(configuration, query);
|
||||
Statement stmt = c.createStatement(sql = rendered.sql);
|
||||
new DefaultBindContext(configuration, null, new R2DBCPreparedStatement(configuration, stmt)).visit(rendered.bindValues);
|
||||
if (query.isExecutable()) {
|
||||
Rendered rendered = rendered(configuration, query);
|
||||
Statement stmt = c.createStatement(sql = rendered.sql);
|
||||
new DefaultBindContext(configuration, null, new R2DBCPreparedStatement(configuration, stmt)).visit(rendered.bindValues);
|
||||
|
||||
// TODO: Reuse org.jooq.impl.Tools.setFetchSize(ExecuteContext ctx, int fetchSize)
|
||||
AbstractResultQuery<?> q1 = abstractResultQuery(query);
|
||||
if (q1 != null) {
|
||||
int f = SettingsTools.getFetchSize(q1.fetchSize(), configuration.settings());
|
||||
// TODO: Reuse org.jooq.impl.Tools.setFetchSize(ExecuteContext ctx, int fetchSize)
|
||||
AbstractResultQuery<?> q1 = abstractResultQuery(query);
|
||||
if (q1 != null) {
|
||||
int f = SettingsTools.getFetchSize(q1.fetchSize(), configuration.settings());
|
||||
|
||||
if (f != 0) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Setting fetch size", f);
|
||||
if (f != 0) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Setting fetch size", f);
|
||||
|
||||
stmt.fetchSize(f);
|
||||
stmt.fetchSize(f);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractDMLQuery<?> q2 = abstractDMLQuery(query);
|
||||
if (q2 != null
|
||||
&& !q2.returning.isEmpty()
|
||||
|
||||
|
||||
|
||||
&& !q2.nativeSupportReturningOrDataChangeDeltaTable(configuration.dsl()))
|
||||
stmt.returnGeneratedValues(Tools.map(q2.returningResolvedAsterisks, Field::getName, String[]::new));
|
||||
|
||||
stmt.execute().subscribe(resultSubscriber.apply(query, downstream));
|
||||
}
|
||||
else {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Query is not executable", query);
|
||||
|
||||
AbstractDMLQuery<?> q2 = abstractDMLQuery(query);
|
||||
if (q2 != null
|
||||
&& !q2.returning.isEmpty()
|
||||
|
||||
|
||||
|
||||
&& !q2.nativeSupportReturningOrDataChangeDeltaTable(configuration.dsl()))
|
||||
stmt.returnGeneratedValues(Tools.map(q2.returningResolvedAsterisks, Field::getName, String[]::new));
|
||||
|
||||
stmt.execute().subscribe(resultSubscriber.apply(query, downstream));
|
||||
Subscriber<Result> s = resultSubscriber.apply(query, downstream);
|
||||
s.onSubscribe(new NoOpSubscription(s));
|
||||
}
|
||||
}
|
||||
|
||||
// [#13343] Cancel the downstream in case of a rendering bug in jOOQ
|
||||
@ -466,6 +475,18 @@ final class R2DBC {
|
||||
}
|
||||
}
|
||||
|
||||
static final record NoOpSubscription(Subscriber<?> subscriber) implements Subscription {
|
||||
@Override
|
||||
public void request(long n) {
|
||||
subscriber.onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
subscriber.onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
static final class BatchMultipleSubscriber extends ConnectionSubscriber<Integer> {
|
||||
|
||||
final BatchMultiple batch;
|
||||
@ -1568,7 +1589,11 @@ final class R2DBC {
|
||||
@Override
|
||||
final void request0() {
|
||||
try {
|
||||
subscriber.onNext(query.execute());
|
||||
if (query.isExecutable())
|
||||
subscriber.onNext(query.execute());
|
||||
else if (log.isDebugEnabled())
|
||||
log.debug("Query is not executable", query);
|
||||
|
||||
subscriber.onComplete();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user