Hey, I have a read query that uses pg_trgm
and I want to set word_similarity_threshold
before running it.
I tried something like this:
read :by_entity do
argument :entity_full_name, :string, allow_nil?: false
prepare fn query, context ->
Ash.Query.before_action(query, fn query ->
Pacman.Repo.query!("set pg_trgm.word_similarity_threshold = 0.99") |> dbg()
query
end)
end
filter expr(fragment("(? %> ?)", first_grantee_full_name, ^arg(:entity_full_name))
and not is_nil(recording_date || instrument_date)
and (recording_date || instrument_date) >= ago(2, :year)
and not deleted?)
prepare build(sort: [:recording_date])
end
But this doesn’t seem to work, I believe because there is no commit
query encapsulating both queries inside the same transaction.
What would be the best way to achieve this with Ash?