I am trying to extend jOOQ with PostgreSQL's full-text search in type-safe way using Kotlin's extension functions.
My problem is DSL.function doesn't "know" my custom classes/types TsQuery and TsVector and throws an exception. The Function class itself doesn't have a public constructor.
org.jooq.exception.SQLDialectNotSupportedException: Type class jooq.fulltext.TsVector is not supported in dialect DEFAULT
class TsQuery
class TsVector
fun Field<String>.toTsVector(searchConfig: String): Field<TsVector> {
return DSL.function(
"to_tsvector",
TsVector::class.java,
DSL.inline(searchConfig),
DSL.coalesce(this, "")
)!!
}
fun String.toTsQuery(searchConfig: String): Field<TsQuery> {
return DSL.function(
"to_tsquery",
TsQuery::class.java,
DSL.inline(searchConfig),
DSL.value(this)
)!!
}
fun Field<TsVector>.tsMatches(query: Field<TsQuery>): Condition {
return DSL.condition(
"{0} @@ {1}",
this,
query
)!!
}
fun Field<TsVector>.tsRank(query: Field<TsQuery>): Field<Double> {
return DSL.function(
"ts_rank",
Double::class.java,
this,
query
)!!
}
If I replace TsQuery and TsVector with String then it works, but I loose typing. I want to use them only for query building, I do not need to be able to parse/convert those types to/from Kotlin.