https://kotlinlang.org logo
#komapper
Title
# komapper
d

dave08

12/10/2023, 12:40 PM
@Toshihiro Nakamura How do I define a
FROM_UNIXTIME(?)
for mysql (to be used in a where statement:
a.field1 > FROM_UNIXTIME(?)
)?
t

Toshihiro Nakamura

12/11/2023, 12:44 PM
This is a kind of workaround, but you can write it this way.
Copy code
private fun fromUnixTime(value: Long): ColumnExpression<LocalDateTime, LocalDateTime> {
    val name = "fromUnixTime"
    val o1 = Operand.Argument(literal(0L), value)
    return columnExpression(LocalDateTime::class, LocalDateTime::class, { it }, name, listOf(o1)) {
        append("FROM_UNIXTIME(")
        visit(o1)
        append(")")
    }
}
I’ll think about whether we can provide a better method in the next version.
d

dave08

12/11/2023, 12:47 PM
Ok, thanks! I can give that a try.
2 Views