How can I get around `Overload resolution ambiguit...
# getting-started
g
How can I get around
Overload resolution ambiguity
for a function that has two
varargs
single-argument signatures?
Copy code
Overload resolution ambiguity. All these functions match.
public open fun <T : Any!> array(vararg values: TypeVariable(T)!): Field<Array<(out) TypeVariable(T)!>!> defined in org.jooq.impl.DSL
public open fun <T : Any!> array(vararg fields: Field<TypeVariable(T)!>!): Field<Array<(out) TypeVariable(T)!>!> defined in org.jooq.impl.DSL
It works in Java, but not in Kotlin. I can't use
null
or `emptyArray()`/`emptyList()` because that produces the wrong results =/
e
Copy code
DSL.array(*emptyArray<T>())
DSL.array(*emptyArray<Field<T>>())
but looking at the javadoc, there's a non-varargs overload that you could use instead, if that is your intended result
Copy code
DSL.array(emptyList<T>())
(but what use is an empty array in jOOQ?)
g
@ephemient Sorry, meant to follow up on this but it slipped my mind The author answered here on StackOverflow if you're curious: https://stackoverflow.com/questions/74451231/jooq-how-to-select-an-empty-array-in-kotlin/74457479
(but what use is an empty array in jOOQ?)
Ah, I need it to coalesce potentially
null
aggregation results in a
JSON
object, for a custom SQL dialect that isn't supported by default
coalesce(some_agg_column, [])
569 Views