Skip to content

Commit 90ce6b7

Browse files
authored
fix: respect read action sort if relationship does not specify one (#194)
1 parent c2717eb commit 90ce6b7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/join.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,17 @@ defmodule AshSql.Join do
445445
)
446446
end
447447
end)
448-
|> Ash.Query.unset([:sort, :distinct, :select, :limit, :offset])
448+
|> Ash.Query.unset([:distinct, :select, :limit, :offset])
449449
|> handle_attribute_multitenancy(tenant)
450450
|> hydrate_refs(context[:private][:actor])
451451
|> then(fn query ->
452452
if sort? do
453-
Ash.Query.sort(query, relationship.sort)
453+
query
454+
|> Ash.Query.unset(:sort)
455+
|> Ash.Query.sort(relationship.sort || query.sort)
454456
else
455-
Ash.Query.unset(query, :sort)
457+
query
458+
|> Ash.Query.unset(:sort)
456459
end
457460
end)
458461
|> set_has_parent_expr_context(relationship)

0 commit comments

Comments
 (0)