Order by multiple computed columns
Hey y'all I'm trying to accomplish a query similar this query using Postgres’ text similarity function.
I’ve tried using drizzle’s query builder like so:
But I’m running into a type error on my orderBy clause saying my_view.col1 is of type any and thus not assignable to orderBy(). If I remove the second order by argument then everything works fine, but I need both. Additionally when I use toSQL() on this query, I notice that in the select values there are no ‘as’ keywords inserted to alias my similarity columns and thus in the orderBy clause it is re-running similarity(col, val) function which would really slow down the query.
Any help on how to accomplish this query using the query builder or should I just do a db.execute() on the above SQL statement?
1 Reply
The generated sql looks like this when I only order by one calculated column.