8000 Pagination: support pagination's `count` on actions besides reads by davidebriani · Pull Request #1229 · ash-project/ash · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pagination: support pagination's count on actions besides reads #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

davidebriani
Copy link
Contributor

Read actions support specifying pagination options on load statements for relationships.
These options are correctly respected, and the count: true option results in Ash counting the total number of related resources and returning the count in the page returned as the loaded relationship.

However, actions such as Ash.update!/3 do not properly respect the load option since the resulting count field is left as nil.

The PR adds a sample failing test.

Contributor checklist

  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@zachdaniel
Copy link
Contributor

@rbino would you have a few to look into this?

@davidebriani davidebriani force-pushed the update-not-returning-pagination-count branch from 17df397 to b3a3d3d Compare June 8, 2024 16:23
@davidebriani davidebriani force-pushed the update-not-returning-pagination-count branch from b3a3d3d to f517af9 Compare June 10, 2024 14:11
@davidebriani davidebriani marked this pull request as ready for review June 10, 2024 14:13
Ensure that relationships can be correctly loaded, even with pagination,
on the resources resulting from create, update and delete actions.

Signed-off-by: Davide Briani <davide.briani@secomind.com>
@davidebriani davidebriani force-pushed the update-not-returning-pagination-count branch from f517af9 to 04057ad Compare June 10, 2024 14:40
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

@zachdaniel zachdaniel merged commit ae96711 into ash-project:main Jun 10, 2024
30 checks passed
@@ -178,6 +178,8 @@ defmodule Ash.Actions.Read do

query = load_and_select_sort(query)

query = add_relationship_count_aggregates(query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is now done here shouldn't it be removed from line 435?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that and push it up

@davidebriani davidebriani deleted the update-not-returning-pagination-count branch June 19, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants
0