https://kotlinlang.org logo
#exposed
Title
# exposed
d

Dirk

06/02/2023, 8:29 AM
Hello, I have a question about joins and aliases. I have (see code in the next message) a query for which I create an alias and which is then to be used as a join argument. But unfortunately it is not clear to me how the fields can be accessed. In the current attempt I get the error message "Field not found in original table fields". I also use my own function, which I also attach.
image.png
Copy code
class JSO<T>(private val column: Expression<*>, override val columnType: IColumnType, private val path: String) : Function<T>(columnType) {
    override fun toQueryBuilder(queryBuilder: QueryBuilder) = queryBuilder {
        <http://log.info|log.info>("-----> JsonValue soll generiert werden. column: $column, path: $path, columntyp: $columnType")
        append("JSON_VALUE(")
        column.toQueryBuilder(queryBuilder)
        append(", '$.")
        append(path)
        append("')")
    }
}

inline fun <FeldTyp, reified ColumnTyp> Column<*>.JSV(path: String): Function<FeldTyp>
        where ColumnTyp : IColumnType,
              FeldTyp : IHasColumntyp =
    JSO(this, ColumnTyp::class.primaryConstructor!!.call(), path)
3 Views