ash-project / ash_postgres

The PostgreSQL data layer for Ash Framework
https://hexdocs.pm/ash_postgres
MIT License
139 stars 75 forks source link

parent does not work from within an aggregate filter #287

Closed kernel-io closed 5 months ago

kernel-io commented 5 months ago

When attempting to use parent from within an aggregates filter the following error is thrown Unsupported expression in Elixir.AshPostgres.SqlImplementation query: %{attribute: :queue_id, resource: nil, __struct__: Ash.Query.Ref, relationship_path: [], bare?: nil, input?: nil, simple_equality?: nil}

The workaround is to place the parent within a filter defined on the relationship.

Expectation is that parent is available in all contexts.

count :open_count, :transactions do
  filter expr(status != :completed and queue_id == parent(queue_id))
end

throws an error, a filter needs to be defined on the transactions relationship as such.

filter expr(queue_id == parent(queue_id))
zachdaniel commented 5 months ago

🙇