Open dreaming-augustin opened 5 years ago
Other libraries have similar problems. Here are a couple of examples, and the solutions they offer:
PDO Int placeholders getting quotes around them https://stackoverflow.com/questions/15984025/pdo-int-placeholders-getting-quotes-around-them
$stm->bindValue(2, ($request-1)*4), PDO::PARAM_INT);
Here, the PDO library offers the possibility to explicitly state the type of the parameter.
JSON_EXTRACT comparison/casting issue #348 https://github.com/sidorares/node-mysql2/issues/348
Having a mysql table with a JSON field, I can easily select any integer included in the JSON object with the simple query:
And I can extract the integer in the usual fashion:
Now, the same does not work if I want to bind the integer to search within the JSON field:
With the above statement, the integer 123 is bound as a string. As a result, the query always fails to select appropriate entries, because it is comparing integers to strings.
The workaround is to force casting the integer... back to an integer this way:
It is obviously not ideal. I am not sure whether it is a problem with cppdb or with the mysql library that cppdb uses.