vertx-mysql-postgresql-client icon indicating copy to clipboard operation
vertx-mysql-postgresql-client copied to clipboard

MySQL TIME columns don't work

Open mslenc opened this issue 6 years ago • 8 comments

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)

mslenc avatar Oct 20 '17 17:10 mslenc

can you provide a reproducer test ?

vietj avatar Oct 20 '17 21:10 vietj

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

mslenc avatar Oct 20 '17 21:10 mslenc

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.

Narigo avatar Dec 07 '17 23:12 Narigo

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

mslenc avatar Dec 08 '17 14:12 mslenc

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

Update: PR is updated

Narigo avatar Dec 10 '17 14:12 Narigo

Is there any workaround for this problem?

kirillkh avatar Mar 06 '18 21:03 kirillkh

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

tsegismont avatar Mar 12 '18 17:03 tsegismont

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

kirillkh avatar Mar 13 '18 23:03 kirillkh