vert-x3 / vertx-mysql-postgresql-client

This client is deprecated - use instead
https://github.com/eclipse-vertx/vertx-sql-client
Apache License 2.0
117 stars 59 forks source link

MySQL TIME columns don't work #92

Open mslenc opened 7 years ago

mslenc commented 7 years ago

The stack trace is:

Caused by: java.lang.IllegalStateException: Illegal type in JsonObject: class scala.concurrent.duration.FiniteDuration
    at io.vertx.core.json.Json.checkAndCopy(Json.java:215)
    at io.vertx.core.json.JsonArray.add(JsonArray.java:444)
    at io.vertx.ext.asyncsql.impl.ScalaUtils.convertValue(ScalaUtils.java:138)
vietj commented 7 years ago

can you provide a reproducer test ?

mslenc commented 7 years ago

As far as I can tell, this will reproduce the problem:

  1. Create a table with a TIME column
  2. Put some data in that column
  3. Try to query for it..
Narigo commented 6 years ago

I could create a reproducer for this problem. In PostgreSQL, TIME returns org.joda.time.LocalTime, in MySQL it returns scala.concurrent.duration.FiniteDuration.

What kind of return value would you expect? For MySQL / FiniteDuration I'd go for a number in milliseconds and LocalTime I'd return as String (HH:MM:SS.<milliseconds>). There is a difference between PostgreSQL and MySQL regarding the column type TIME, so I think it might make sense to reflect that in the return value as well.

mslenc commented 6 years ago

Yeah, MySQL's TIME is somewhat ambiguous in meaning, and can be used for both durations and times.. But still, I wouldn't encode them differently, that it becomes a FiniteDuration seems more of an implementation artifact than anything else.. HH:MM:SS will match both what the database itself is returning (and expecting to receive!), as well as the PostgreSQL version..

Narigo commented 6 years ago

Ok, then I'll make it return "HH:MM:SS." in all cases.

Update: PR is updated

kirillkh commented 6 years ago

Is there any workaround for this problem?

tsegismont commented 6 years ago

@kirillkh you could update your queries to convert the time column with TO_CHAR, then in the verticle retrieve the time as a String

kirillkh commented 6 years ago

What worked for me: TABLE.TIME.cast(String.class)