Daniel
03/23/2023, 11:34 AMprivate suspend fun <T> executeQuery(timeout: Duration = 3.seconds, block: suspend Transaction.() -> T): T =
withTimeout(timeout) { newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>) { block() } }
public suspend fun test1() = executeQuery(10.seconds) {
with(SomeTable) {
slice(id, other_id, valid_from).select {
(status eq BigDecimal.ONE) and (someFlag eq BigDecimal.ZERO) and
(CurrentDateTime.between(valid_from, valid_to))
}.forEach {
println("$it")
}
}
}
but I am getting Exception in thread "main" java.lang.IllegalStateException: Unexpected value: com.example.MayDatabase$SomeTable.valid_from of org.jetbrains.exposed.sql.Column
I am not sure what I am doing wrong. Very similar code to this worked beforeBerkay Özkan
03/23/2023, 11:36 AMDaniel
03/23/2023, 11:40 AMobject SomeTable : Table("some_table") {
...
val valid_from = datetime("valid_from")
val valid_to = datetime("valid_to")
...
}
Berkay Özkan
03/23/2023, 11:41 AMimport org.jetbrains.exposed.sql.javatime.datetime
right?Daniel
03/23/2023, 11:41 AMDaniel
03/23/2023, 11:48 AMbetween
function. When I substituted it by (valid_from less CurrentDateTime) and (valid_to greater CurrentDateTime)
it started workingDaniel
03/23/2023, 12:24 PMbetween
function is defined as
fun <T, S : T?> ExpressionWithColumnType<S>.between(from: T, to: T): Between = Between(this, wrap(from), wrap(to))
where it wraps those parameters into QueryParameter<T>
unconditionally, it makes it not work correctly when you pass it`Column<T>` . I experimentally created modified version like this:
fun <T, S : T?> ExpressionWithColumnType<S>.between(from: T, to: T): Between =
Between(this, if (from is Column<*>) { from } else { wrap(from) }, if (to is Column<*>) { to } else { wrap(to) })
which seems to work correctly. Do you think its worth a PR?