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
5 changes: 2 additions & 3 deletions lib/arke_postgres/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule ArkePostgres.Query do
%{filters: filters, orders: orders, offset: offset, limit: limit} = arke_query,
action
) do
paths = extract_paths(filters) ++ extract_paths(orders)
paths = extract_paths(filters ++ orders)

base_query(arke_query, action)
|> handle_paths_join(paths)
Expand Down Expand Up @@ -316,7 +316,6 @@ defmodule ArkePostgres.Query do
defp handle_paths_join(query, paths) do
paths
# dedupe based on the first parameter id that will be used to join
|> Enum.uniq_by(fn [%{id: id} | _] -> id end)
|> Enum.reduce(query, &build_join/2)
end

Expand All @@ -329,7 +328,7 @@ defmodule ArkePostgres.Query do
items
|> Enum.flat_map(&extract_path/1)
|> Enum.reject(&(is_nil(&1) or length(&1) == 0))
|> Enum.uniq()
|> Enum.uniq_by(fn [%{id: id} | _] -> id end)
Copy link
Member

Choose a reason for hiding this comment

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

If you do that here you're rejecting two filters on the same parameter link_owner.first_name and link_owner.last_name won't work in the same api call :C

end

def extract_path(%Arke.Core.Query.Filter{base_filters: base_filters}),
Expand Down