vertx-sql-client
vertx-sql-client copied to clipboard
Prepared statements with positional arguments(`$1`, `$2 ` etc) do not work for db2
Version
3.9.5
Context
I encountered an exception which looks suspicious while trying to reproduce examples from db2 client documentation(https://vertx.io/docs/3.9.5/vertx-db2-client/java/#_prepared_queries).
Do you have a reproducer?
- https://github.com/fedinskiy/reproducer/tree/c8ae9bcca60a01b78025b5602fbc59c0085b2f82
To reproduce: run mvn clean test.
- Test preparedQueryJDBC is working fine, its query is
SELECT * FROM users WHERE id=? - Test preparedQueryBash fails, its query is
SELECT * FROM users WHERE id=$1The rest of these two tests is the same.
Steps to reproduce
- Create prepared query for db2 database with positional arguments (
$1,$2etc) - Run query
- Query fails with the exception
io.vertx.db2client.DB2Exception: The column '$1' provided does not exist
The same query works successfully, if ran with ? arguments
for DB2 you need to use DB2 syntax which is ?
this is expected and not a bug.
@vietj in that case, documentation should be fixed, since code examles(https://vertx.io/docs/3.9.5/vertx-db2-client/java/#_prepared_queries) currently use both syntaxes.
Fixed in 76c6083 and backported to 4.3, 4.2 and 3.9