https://kotlinlang.org logo
j

Joel

09/16/2020, 2:52 PM
Is there a way to wrap a constant as a query? i.e.
SELECT 1
v

Vinicius Araujo

09/16/2020, 7:49 PM
this is what I did:
Copy code
object One : Expression<String>() {
    override fun toQueryBuilder(queryBuilder: QueryBuilder) = queryBuilder { append("1") }
}
and use like
slice(One)
t

tapac

09/17/2020, 7:41 PM
There is
intLiteral
and
intParam
functions for that, but you have to declare some fake table, like DUAL in Mysql.
Copy code
object DualTable : Table("DUAL") 

DualTable.slice(intLiteral(1)).selectAll()
j

Joel

09/17/2020, 11:13 PM
@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) }
😄
3 Views