Where do I find documentation on `contains()` , for use within an Ash.Query.filter()?

I checked: 1. Ash.Filter: https://ash-hq.org/docs/module/ash/latest/ash-filter 2. Ash.Query: https://ash-hq.org/docs/module/ash/latest/ash-query 2. Ash.Query.filter() (which was not in alphabetical order in the Ash.Query functions list on the right side): https://ash-hq.org/docs/module/ash/latest/ash-query#macro-filter-2 Where can the documentation for contains() be found?
Ash HQ
Module: Ash.Filter
View the documentation for Ash.Filter on Ash HQ.
Ash HQ
Module: Ash.Query
View the documentation for Ash.Query on Ash HQ.
10 Replies
moxley
moxleyOP2y ago
And I guess the bigger question is: Can Ash do SQL queries anywhere near as well as Ecto can? If I have a really complex SQL query, will I be able to do it in Ash? Ecto as fragment() and ilike(), and others. I think I'll need that functionality in the future. And if it can't do those things, what are my options?
ZachDaniel
ZachDaniel2y ago
I should link there from some of those places that you searched 🙂 There are also data layer specific expressions which I'm realizing now I cannot find the documentation for unfortunately. I'll add a guide right now To answer your specific question, Ash has fragment/1 and so at the end of the day you can basically do anything you need. even if you've got to put a big ugly sql query into a calculation There are solutions if that problem gets really bad (defining views/functions in postgres), and although it can be a bit of a paradigm shift, combinations of aggregates/calculations (aggregates allow referring to calculations of related resources even) and some of the new expressions we've added like exists/2 can take you a very long way. And then in the worst case scenarios you have:
read :read do
modify_query fn ash_query, ecto_query ->
{:ok, new_ecto_query}
end
end
read :read do
modify_query fn ash_query, ecto_query ->
{:ok, new_ecto_query}
end
end
moxley
moxleyOP2y ago
Oh nice!
ZachDaniel
ZachDaniel2y ago
I think the most important thing to know here is that we're building a data-layer agnosting querying layer overtop of multiple data layers. All of those expressions listed in the expressions guide will work against any data layer that implements them, and that will be all core supported data layers like Ets Mnesia Csv and AshPostgres but we understand that that is not always enough, hence deeper escape hatches & fragment/* existing
moxley
moxleyOP2y ago
Sure, I get that.
ZachDaniel
ZachDaniel2y ago
👍 the main consequence is that sometimes you have to find "resource-y" ways to state your query (and sometimes of course can't always do that). I.e "count of users grouped by org" would really be:
aggregates do
count :count_of_users, :users
end
aggregates do
count :count_of_users, :users
end
on the organization resource here is a doc on expressions added by postgres
ZachDaniel
ZachDaniel2y ago
GitHub
ash_postgres/documentation/topics/postgres-expressions.md at main ·...
A postgresql datalayer for the Ash Framework. Contribute to ash-project/ash_postgres development by creating an account on GitHub.
ZachDaniel
ZachDaniel2y ago
not deployed to ash-hq yet, will go out w/ the next release It has fragment like, ilike and trigram_similarity

Did you find this page helpful?