Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading a date from DB on Android fails #991

Closed
Namnodorel opened this issue Jul 8, 2020 · 2 comments
Closed

Reading a date from DB on Android fails #991

Namnodorel opened this issue Jul 8, 2020 · 2 comments

Comments

@Namnodorel
Copy link
Contributor

When attempting to read from a table with a LocalDate/LocalDateTime (using exposed-java-time) on Android, Exposed will fail with the following exception:

Caused by: java.lang.NoSuchMethodError: No virtual method toLocalDate()Ljava/time/LocalDate; in class Ljava/sql/Date; or its super classes (declaration of 'java.sql.Date' appears in /apex/com.android.runtime/javalib/core-oj.jar)
        at org.jetbrains.exposed.sql.java-time.JavaLocalDateColumnType.valueFromDB(JavaDateColumnType.kt:49)
        at org.jetbrains.exposed.sql.ResultRow.rawToColumnValue(ResultRow.kt:46)
        at org.jetbrains.exposed.sql.ResultRow.get(ResultRow.kt:25)

As far as I can tell, this is because Android doesn't provide this method in its implementation of java.sql.Date. I think this could be easily worked around by replicating the methods functionality within Exposed.

Note that inserting dates into the DB appears to work fine.

@Tapac
Copy link
Contributor

Tapac commented Jul 8, 2020

@Namnodorel , thank you for a report. Will be fixed within next release.

@Tapac Tapac closed this as completed Jul 8, 2020
@Namnodorel
Copy link
Contributor Author

Namnodorel commented Jul 20, 2020

Unfortunately, I appear to have missed an aspect of this before - the same problem exists with JavaLocalDateTimeColumnType.notNullValueToDB.

Tapac pushed a commit that referenced this issue Jul 20, 2020
The current fix for #991 missed the usage of `Timestamp.from()`. This change should fix that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants