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

Max timestamp in Sqlite not working #1084

Closed
ne3ma-ibraheem opened this issue Nov 5, 2020 · 0 comments · Fixed by #1725
Closed

Max timestamp in Sqlite not working #1084

ne3ma-ibraheem opened this issue Nov 5, 2020 · 0 comments · Fixed by #1725

Comments

@ne3ma-ibraheem
Copy link

ne3ma-ibraheem commented Nov 5, 2020

Kotlin Version: 1.4.20-M1 - Exposed Version : 0.28.1 - Sqlite jdbc version : 3.32.3.2

I am trying to get the max value of timestamp column from a table in Sqlite and got the following exception:

java.time.format.DateTimeParseException: Text '2020-11-05 12:15:13.617' could not be parsed at index 10

And here is the test that reproduce the issue:

import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.`java-time`.timestamp
import org.jetbrains.exposed.sql.transactions.transaction
import org.junit.Test
import java.time.Instant
object TestTable: Table(){
    val timestamp = timestamp("dt")
}
class TimestampTestFailureSqlite {
 @Test
    fun shouldReturnMaxTimestamp(){
        Database.connect("jdbc:sqlite:file:test?mode=memory&cache=shared")
        transaction {
            addLogger(StdOutSqlLogger)
            SchemaUtils.create(TestTable)
            TestTable.insert {
                it[timestamp] = Instant.now()
            }
            val maxDate = TestTable.timestamp.max()
            TestTable.slice(maxDate).selectAll().map {
                it[maxDate]
            }
        }
}}

And here is the output of the SQL Logger

SQL: CREATE TABLE IF NOT EXISTS Test (dt TEXT NOT NULL)
SQL: INSERT INTO Test (dt) VALUES ('2020-11-05T12:15:13.617164')
SQL: SELECT MAX(Test.dt) FROM Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants