Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/join.ex
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,17 @@ defmodule AshSql.Join do
)
end
end)
|> Ash.Query.unset([:sort, :distinct, :select, :limit, :offset])
|> Ash.Query.unset([:distinct, :select, :limit, :offset])
|> handle_attribute_multitenancy(tenant)
|> hydrate_refs(context[:private][:actor])
|> then(fn query ->
if sort? do
Ash.Query.sort(query, relationship.sort)
query
|> Ash.Query.unset(:sort)
|> Ash.Query.sort(relationship.sort || query.sort)
else
Ash.Query.unset(query, :sort)
query
Copy link
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
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

|> Ash.Query.unset(:sort)
end
end)
|> set_has_parent_expr_context(relationship)
Expand Down