Skip to content

respect read action sort if relationship does not specify one#194

Merged
zachdaniel merged 3 commits intomainfrom
fix/join-sort
Nov 21, 2025
Merged

respect read action sort if relationship does not specify one#194
zachdaniel merged 3 commits intomainfrom
fix/join-sort

Conversation

@barnabasJ
Copy link
Copy Markdown
Contributor

@barnabasJ barnabasJ commented Nov 18, 2025

Test for this in ash-project/ash_postgres#654

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

Comment thread lib/join.ex Outdated
query
end
end)
|> Ash.Query.unset([:distinct, :select, :limit, :offset])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need all three of these unset?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, my bad. I think i copied them together with an IO.inspect and only removed the inspect. Fixed now

Comment thread lib/join.ex
|> Ash.Query.sort(relationship.sort)
else
Ash.Query.unset(query, :sort)
query
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sort? being false means that we aren't in a situation where sorting should happen at all (like exists/2. I think you want to always unset the sort, and then set the sort to relationship.sort || query.sort, and if sort? is false then you just unset it so we don't sort for no reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, I miss-interpreted what sort? stood for, fixed

@zachdaniel zachdaniel merged commit 90ce6b7 into main Nov 21, 2025
23 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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.

2 participants