chore: small cleanups

This commit is contained in:
Zach Daniel 2022-06-04 16:57:54 -04:00
parent c54c67af9d
commit 10c7e75f4a
2 changed files with 3 additions and 36 deletions

View file

@ -1288,40 +1288,7 @@ defmodule AshPostgres.DataLayer do
%{distinct | expr: distinct.expr ++ expr}
end
# defp order_by_distinct(query, resource, distinct_on) do
# query
# |> default_bindings(resource)
# |> Map.update!(:distinct, fn distinct ->
# distinct =
# distinct ||
# %Ecto.Query.QueryExpr{
# expr: []
# }
# expr =
# Enum.map(distinct_on, fn distinct_on_field ->
# binding =
# case Map.fetch(query.__ash_bindings__.aggregates, distinct_on_field) do
# {:ok, binding} ->
# binding
# :error ->
# 0
# end
# {:asc, {{:., [], [{:&, [], [binding]}, distinct_on_field]}, [], []}}
# end)
# %{distinct | expr: expr ++ distinct.expr}
# end)
# end
@impl true
def filter(query, %{expression: false}, _resource) do
impossible_query = from(row in query, where: false)
{:ok, Map.put(impossible_query, :__impossible__, true)}
end
def filter(query, filter, resource) do
query = default_bindings(query, resource)

View file

@ -16,11 +16,11 @@ defmodule AshPostgres.Expr do
end
# A nil filter means "everything"
def dynamic_expr(_, nil, _, _, _), do: {[], true}
def dynamic_expr(_, nil, _, _, _), do: true
# A true filter means "everything"
def dynamic_expr(_, true, _, _, _), do: {[], true}
def dynamic_expr(_, true, _, _, _), do: true
# A false filter means "nothing"
def dynamic_expr(_, false, _, _, _), do: {[], false}
def dynamic_expr(_, false, _, _, _), do: false
def dynamic_expr(query, expression, bindings, embedded?, type) do
do_dynamic_expr(query, expression, bindings, embedded?, type)