dave08
04/10/2024, 12:30 PMClock.todayIn(TimeZone.UTC)
, I don't know what to use... shouldn't there be a localDateLiteral for this (in jetbrains exposed they actually have such a function...)?dave08
04/10/2024, 12:31 PMinsert(...).select { ... }
so I don't have a choice..dave08
04/10/2024, 12:45 PMdave08
04/10/2024, 12:52 PMfun literalLocalDate(date: LocalDate): ColumnExpression<String, String> =
literal(date.toString().replace("-",""))
Toshihiro Nakamura
04/10/2024, 12:59 PM.selectAsAddressDto(
street = a.street,
date = nullLitral<LocalDate>.transform { Clock.todayIn(TimeZone.UTC) },
)
dave08
04/10/2024, 1:08 PMjava.lang.UnsupportedOperationException
at org.komapper.core.dsl.expression.NullLiteralExpression.getOwner(LiteralExpression.kt:13)
dave08
04/10/2024, 1:11 PMdata class NullLiteralExpression<EXTERNAL : Any, INTERNAL : Any>(
override val exteriorClass: KClass<EXTERNAL>,
override val interiorClass: KClass<INTERNAL>,
) :
LiteralExpression<EXTERNAL, INTERNAL> {
override val owner: TableExpression<*>
get() = throw UnsupportedOperationException()
selectAsEntity seems to try to access that owner property @Toshihiro Nakamura....dave08
04/10/2024, 1:13 PMbut instead, you want to set data within your application, right?exactly...
dave08
04/10/2024, 1:14 PM@KomapperUpdateAt
to update it in that particular case...dave08
04/10/2024, 1:14 PMToshihiro Nakamura
04/10/2024, 1:55 PMfun todayIn(): ColumnExpression<LocalDate, LocalDate> {
val operand = Operand.SimpleArgument(LocalDate::class, Clock.todayIn(TimeZone.UTC))
return columnExpression(LocalDate::class, "todayIn", listOf(operand)) {
visit(operand)
}
}
Use the above function as follows:
QueryDsl.insert(a).select {
QueryDsl.from(a)
.where { a.id eq newAddress.id }
.selectAsEntity(a, a.street, todayIn(), todayIn())
}
dave08
04/10/2024, 2:06 PMliteralLocalDate()
then...
fun literalLocalDate(date: LocalDate): ColumnExpression<LocalDate, LocalDate> {
val operand = Operand.SimpleArgument(LocalDate::class, date)
return columnExpression(LocalDate::class, "literalLocalDate", listOf(operand)) {
visit(operand)
}
}