Skip to content

fix: use aggregate read_action instead of using relationship read#239

Open
averypeck wants to merge 1 commit into
ash-project:mainfrom
averypeck:aggregate-read-action
Open

fix: use aggregate read_action instead of using relationship read#239
averypeck wants to merge 1 commit into
ash-project:mainfrom
averypeck:aggregate-read-action

Conversation

@averypeck

@averypeck averypeck commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Ash.Query.Aggregate.new/4 accepts a read_action parameter: https://ash.hexdocs.pm/Ash.Query.Aggregate.html#new/4, validates it, and sets it on the aggregate.query that it passes to ash_sql. ash_sql ignores that read_action and derives it again from the the relationship:

read_action = Ash.Resource.Info.action(related, read_action)

This PR adds an "override" for resolving the specified read_action on the last relationship in the relationship path for the aggregate. Failing regression tests on this ash_postgres PR provide a reproduction.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@averypeck
averypeck marked this pull request as ready for review July 18, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant