Skip to content

Commit 3a39ab8

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 2057666 commit 3a39ab8

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
@@ -23,7 +23,10 @@
2323
import io.vertx.core.net.ClientSSLOptions;
2424
import io.vertx.core.net.PemTrustOptions;
2525
import io.vertx.docgen.Source;
26-
import io.vertx.pgclient.*;
26+
import io.vertx.pgclient.PgBuilder;
27+
import io.vertx.pgclient.PgConnectOptions;
28+
import io.vertx.pgclient.PgConnection;
29+
import io.vertx.pgclient.SslMode;
2730
import io.vertx.pgclient.pubsub.PgSubscriber;
2831
import io.vertx.sqlclient.*;
2932
import io.vertx.sqlclient.data.Numeric;
@@ -774,7 +777,7 @@ public void batchReturning(SqlClient client) {
774777
.preparedQuery("INSERT INTO color (color_name) VALUES ($1) RETURNING color_id")
775778
.executeBatch(Arrays.asList(Tuple.of("white"), Tuple.of("red"), Tuple.of("blue")))
776779
.onSuccess(res -> {
777-
for (RowSet<Row> rows = res;rows.next() != null;rows = rows.next()) {
780+
for (RowSet<Row> rows = res; rows != null; rows = rows.next()) {
778781
Integer colorId = rows.iterator().next().getInteger("color_id");
779782
System.out.println("generated key: " + colorId);
780783
}

0 commit comments

Comments
 (0)