Skip to content

Commit d669e60

Browse files
committed
Pg doc: incorrect snippet for retrieval of batched insert with returning clause
See #1440 The last rowset was missed because, for this one, rowset.next() is always null. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent d1011cb commit d669e60

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

vertx-pg-client/src/main/java/examples/PgClientExamples.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import io.vertx.core.json.JsonObject;
2323
import io.vertx.core.net.PemTrustOptions;
2424
import io.vertx.docgen.Source;
25-
import io.vertx.pgclient.*;
25+
import io.vertx.pgclient.PgBuilder;
26+
import io.vertx.pgclient.PgConnectOptions;
27+
import io.vertx.pgclient.PgConnection;
28+
import io.vertx.pgclient.SslMode;
2629
import io.vertx.pgclient.pubsub.PgSubscriber;
2730
import io.vertx.sqlclient.*;
2831
import io.vertx.sqlclient.data.Numeric;
@@ -773,7 +776,7 @@ public void batchReturning(SqlClient client) {
773776
.preparedQuery("INSERT INTO color (color_name) VALUES ($1) RETURNING color_id")
774777
.executeBatch(Arrays.asList(Tuple.of("white"), Tuple.of("red"), Tuple.of("blue")))
775778
.onSuccess(res -> {
776-
for (RowSet<Row> rows = res;rows.next() != null;rows = rows.next()) {
779+
for (RowSet<Row> rows = res; rows != null; rows = rows.next()) {
777780
Integer colorId = rows.iterator().next().getInteger("color_id");
778781
System.out.println("generated key: " + colorId);
779782
}

0 commit comments

Comments
 (0)