-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quarkus sql client PreparedQuery.executeBatch number of rows affected always equal to 1 #16338
Comments
cc @tsegismont |
Thanks for the heads-up @geoand . I'll look into it |
@lucafuji this might not be a bug. The Can you try to iterate using |
@tsegismont It seems the returned row set is empty, I made the following changes:
and immediately got a NoSuchElementException
|
@lucafuji it is expected that the My suggestion was to invoke client.preparedQuery(sql)
.executeBatch(prepareBatchParams(paramList))
.map(res -> {
int total = 0;
do {
total += res.rowCount();
} while ((res = res.next()) != null);
return total;
}); |
@tsegismont is your suggestion something we should document somewhere? |
@geoand we could do that. First let's see if this is a misuse of the API or actually a bug. |
seems working now @tsegismont thanks a lot |
For anyone wanting to have all of the actual inserted results from their RETURNING * query instead of just rowCount, this seems to work. |
@zaneschepke this would work too: client.preparedQuery(sql).executeBatch(batch)
.onItem().<RowSet<Row>>transformToMulti(res ->
// Generate a Multi of RowSet items
Multi.createFrom().generator(() -> res, (rs, emitter) -> {
RowSet<Row> next = null;
if (rs != null) {
emitter.emit(rs);
next = rs.next();
}
if (next == null) {
emitter.complete();
}
return next;
})
)
// Transform each RowSet into Multi and Concatenate
.onItem().transformToMultiAndConcatenate(Multi.createFrom()::iterable)
// Transform each Row into MyObject
.onItem().transform(MyObject::from); |
@tsegismont should this be documented? |
@cescoffier where would be document this? |
Closes quarkusio#16338 (cherry picked from commit 77669cf)
Closes quarkusio#16338 (cherry picked from commit 77669cf)
Describe the bug
We are using io.quarkus:quarkus-reactive-pg-client library and quarkus 1.11.1.Final.
We are using the preparedQuery.executeBatch as below, but the rowCount always returns 1 no matter how many rows it updated
Expected behavior
The row count should return actual number of rows updated
Actual behavior
Always returns 1
The text was updated successfully, but these errors were encountered: