mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
chore: small cleanups
This commit is contained in:
parent
c54c67af9d
commit
10c7e75f4a
2 changed files with 3 additions and 36 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue