mvysny / vok-orm

Mapping rows from a SQL database to POJOs in its simplest form
MIT License
21 stars 4 forks source link

Sql2o sometimes won't use Converter #10

Closed mvysny closed 7 months ago

mvysny commented 5 years ago

Created a workaround for this, but it's far better to be fixed in Sql2o: https://github.com/aaberg/sql2o/issues/314

There is a subtle bug in Sql2o which sometimes misdetects the property type. The problem is as follows.

I have an interface Entity<T> with T getId() method. When a class implements this interface, Kotlin compiler outputs two getId() methods: one that returns Object and the other which returns T (the same with setters, setId(Object) and setId(T).

The problem is in PojoMetadata:117 cycle: JVM lists those fields in random order, and sometimes the T-typed one wins, and sometimes the Object-typed wins. That then causes Sql2o to not to pick up a proper converter for that field, and the setter fails.

I've created a workaround for this, in the MysqlQuirks class, but it's better to fix this properly in Sql2o.

mvysny commented 5 years ago

Blocked by https://github.com/aaberg/sql2o/issues/314

mvysny commented 7 months ago

Closed since we no longer use SQL2o behind the scenes: we replaced it with JDBI.