g

    Gustav Elmgren

    3 months ago
    Is it possible to transform
    Column<EntityId<T>>
    to
    ExpressionWithColumnType<T>
    in some way?
    For example, using
    Entity.id.castTo(LongColumnType()
    Would that be stupid?
    The main reason is that I have a method that accepts
    ExpressionWithColumnType<T>
    , and it wont accept the id, but any other parameter. And it works if I use
    castTo
    . But it seems a bit overkill to actually cast (in the generated SQL) it just so the typing works.
    Emil Kantis

    Emil Kantis

    3 months ago
    can you change the method?
    g

    Gustav Elmgren

    3 months ago
    Yeah, I should be able to do that.
    Emil Kantis

    Emil Kantis

    3 months ago
    fun <T> method(expr: ExpressionWithColumnType<T>)
    ->
    fun <T, S : ExpressionWithColumnType<T>> method(expr: S)
    should do the trick, no?
    since
    Column<T>
    extends
    ExpressionWithColumnType<T>
    g

    Gustav Elmgren

    3 months ago
    I think I tried that, but I might have done it completely wrong.
    Type mismatch.
    Required:
    ExpressionWithColumnType<Long>
    Found:
    Column<EntityID<Long>>
    Nvm, it must be my implementation that does something strange. It accepted it when I tried your snippet.
    Oh. The problem is probably because I have
    <T : Comparable<T>, K : ExpressionWithColumnType<in T>>
    , and
    T
    is a simple Long. I guess I could transform it by using
    EntityId()
    Yeah, it all works when I created the related
    EntityId
    . Thanks!