vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

Prepared statements with positional arguments(`$1`, `$2 ` etc) do not work for db2

Open fedinskiy opened this issue 4 years ago • 2 comments

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=$1 The rest of these two tests is the same.

Steps to reproduce

  1. Create prepared query for db2 database with positional arguments ($1, $2 etc)
  2. Run query
  3. 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

fedinskiy avatar Feb 08 '21 09:02 fedinskiy

for DB2 you need to use DB2 syntax which is ?

this is expected and not a bug.

vietj avatar Feb 08 '21 09:02 vietj

@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.

fedinskiy avatar Feb 08 '21 09:02 fedinskiy

Fixed in 76c6083 and backported to 4.3, 4.2 and 3.9

tsegismont avatar Feb 03 '23 16:02 tsegismont