Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
0.8.4-rc
-
None
Description
from #8
The MariaDB implementation of batch inserts with prepared statements currently requires at least one statement to not be part of a batch when doing batch inserts with prepared statements otherwise an error such as the following occurs:
java.lang.IllegalArgumentException: Parameter at position 0 is not set
|
at org.mariadb.r2dbc.MariadbClientParameterizedQueryStatement.execute(MariadbClientParameterizedQueryStatement.java:132)
|
at org.mariadb.r2dbc.MariadbClientParameterizedQueryStatement.execute(MariadbClientParameterizedQueryStatement.java:34)
|
at io.micronaut.data.r2dbc.operations.DefaultR2dbcRepositoryOperations$DefaultR2dbcReactiveRepositoryOperations.lambda$persistAll$18(DefaultR2dbcRepositoryOperations.java:491)
|
at
|
Looking at the validation logic in MariadbClientParameterizedQueryStatement it does this:
|
public Flux<org.mariadb.r2dbc.api.MariadbResult> execute() { |
|
// valid parameters |
for (int i = 0; i < prepareResult.getParamCount(); i++) { |
if (parameters[i] == null) { |
throw new IllegalArgumentException(String.format("Parameter at position %s is not set", i)); |
}
|
}
|
|
if (batchingParameters == null) { |
If you call add() for the last batch statement then all entries in parameters are null and they exist only in batchParameters. It seems to be that this check should only be executed if batchingParameters == null and the validation check should be moved inside the if statement.
This differs to other implementations whereby you can call add() for each statement and execute them no problem. As a result of this I have to place a MariaDB specific hack into the code I am developing to allow batch inserts to execute across different implementations: