maxmello
05/23/2024, 7:56 AMclass Coalesce<out T, S : T?>(
private val expr: ExpressionWithColumnType<S>,
private val alternate: Expression<out T>,
private vararg val others: Expression<out T>
) : Function<S>(expr.columnType)
Shouldn’t it be Function<T>, since T is non-nullable and the point of coalesce is to convert a nullable expression to a non-nullable expression?spand
05/23/2024, 11:21 AMspand
05/23/2024, 11:21 AMspand
05/23/2024, 11:24 AMmaxmello
05/23/2024, 11:56 AMT
can be nullable, but S
is always nullable, and thus the result from Coalesce
is always nullable even if I know it not to be.
In my example, I have implemented concat operator which I want to accept only non-nullable columns/expressions:
(name concatSpaced description concatSpaced author concatSpaced coalesce(publisher, stringLiteral("")).toTsVector()
Here, publisher is nullable, but this would not compile because Coalesce
is Function<S>
not Function<T>
, so I have to cast it to Expression<String>
manuallyChantal Loncle
05/31/2024, 1:56 PM