Vertx Pg Client Batch Insert rowCount always return 1

25 views
Skip to first unread message

Hantsy Bai

unread,
May 5, 2024, 10:52:21 PMMay 5
to vert.x
I have an example project written with Micronaut, RxJava3, Vertx PgClient.


I try to use the following to insert a list of data.

public Single<Integer> saveAll(List<Post> data) {
        var tuples = data.stream()
                .map(d -> Tuple.of(d.title(), d.content()))
                .toList();

        return client.preparedQuery("INSERT INTO posts (title, content) VALUES ($1, $2)")
                .rxExecuteBatch(tuples)
                .map(SqlResult::rowCount);
    }

In the DataInitializer class, I used to initialize some sample data, but the result of `saveAll` always return 1 in the log.

GERARD Nicolas

unread,
May 6, 2024, 8:19:54 AMMay 6
to vert.x
I'm not a RxJava expert but

Map
is not a reduce function, no?

That your function returns a value is pretty strange.

Reply all
Reply to author
Forward
0 new messages