vert-x3 / vertx-jdbc-client

JDBC support for Vert.x
Apache License 2.0
126 stars 90 forks source link

`SqlOperations` doesn't properly support binary data #315

Open dtwitty opened 6 months ago

dtwitty commented 6 months ago

Version

Version vert.x core, jdbc-client: 4.5.7 RDBMS server : MySQL

Context

I am migrating my app from Vert.x 3.9.13 to 4.5.7. I have encountered a breaking change that is blocking me from completing the migration.

I noticed that when I upgraded Vert.x, my tests started complaining of data truncation reported by MySQL. MySQL was refusing to store by byte[] of length 16 in a BINARY(16) column.

I traced this to how parameters are passed to queries, which is by way of JsonArray. JsonArray.getValue calls JsonArray.wrapJsonValue, which converts byte[] into a Base64-string. This string is longer than 16 bytes, so MySQL refused to store it.

Do you have a reproducer?

No.

Steps to reproduce

  1. Set up a DB schema with a BINARY(16) column
  2. Make an update using SqlOperations.updateWithParams where one of the params is a byte[] of length 16 (this worked on Vert.x 3).
  3. Run the update
  4. The update query fails! MySQL complains that the incoming data doesn't fit in the column.

Extra

Using JVM 11.0.8-msft

dtwitty commented 1 month ago

Hi there @vietj,

Any thoughts on how we could get around this issue?