[CONJ-643] PreparedStatement::getParameterMetaData always returns VARSTRING as type resulting in downstream libraries interpreting values wrongly Created: 2018-09-04  Updated: 2019-02-08  Resolved: 2018-09-05

Status: Closed
Project: MariaDB Connector/J
Component/s: metadata
Affects Version/s: 2.2.6
Fix Version/s: 2.3.0, 1.8.0

Type: Bug Priority: Major
Reporter: Isen Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

MySQL 5.7.14



 Description   

When `PreparedStatement::getParameterMetaData` is performed for a query (for example, an insert query), the sql type for the parameters reports a wrong type, in fact, it is always VARSTRING.

From https://jira.mariadb.org/browse/CONJ-568, I understand it's because the MariaDB server doesn't return the parameter types, and I have a feeling in my case, the MySQL server isn't returning parameter types as well.

However, I personally feel this is wrong. Instead of returning a wrong type, it should throw an exception instead. See how MySql connector does it. Returning wrong types will lead downstream libraries to act on these wrong types and produce wrong results. If an exception is thrown, downstream libraries can act on the exception and perform other/fallback actions.

Because of MariaDB connector returning wrong values, I have to write code to specifically ignore parameter metadata if the jdbc connector is of MariaDB type.



 Comments   
Comment by Diego Dupin [ 2018-09-04 ]

I agree that returning a wrong information make no sense.
A better solution would be to throw an exception. If mysql do that, it won't cause any arm to ORM, but i need to check major one first.

Generated at Thu Feb 08 03:17:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.