Ash.Query fragment inside a select?
Hello, I'm trying to replicate this query with Ash.Query:
Note: Ignore the contants line, that is only to testing.
What I was able to get working is this so far:
What I'm not sure how to do is create that select that will run the
similarity
function and then use it in my order by.
I believe I probably can get that using calculation, but if possible I would like to have that directly in the query.4 Replies
When you say "if possible you would like to have that directly in the query", what do you mean? Like you just want to make sure that its running it in the SQL query?
I would like to be able to do something like this:
Ash.Query.select([fragment("similarity(?, ?) as something", a, b)
so I can reference that in the sort_by
The same way I'm doing in the raw queryAt the moment, you'll need to make it a calculation on the resource
I'd like to support
Ash.Query.sort([expr(...)])
but that isn't currently supported
You could also simplify the expressions by adding a full_name
calculation:
Thank you! That worked like a charm!