Joel

    Joel

    2 years ago
    Is there a way to wrap a constant as a query? i.e.
    SELECT 1
    Vinicius Araujo

    Vinicius Araujo

    2 years ago
    this is what I did:
    object One : Expression<String>() {
        override fun toQueryBuilder(queryBuilder: QueryBuilder) = queryBuilder { append("1") }
    }
    and use like
    slice(One)
    tapac

    tapac

    2 years ago
    There is
    intLiteral
    and
    intParam
    functions for that, but you have to declare some fake table, like DUAL in Mysql.
    object DualTable : Table("DUAL") 
    
    DualTable.slice(intLiteral(1)).selectAll()
    Joel

    Joel

    2 years ago
    @tapac it looks like the
    Query
    object will always append
    FROM
    , which I believe returns the literal value for each row. I am guessing that there is no object that adheres to
    Query
    that doesn't use
    FROM
    😬
    My initial instinct was to try
    wrapAsQuery { intLiteral(1) }
    😄