diff --git a/lib/ash/actions/read.ex b/lib/ash/actions/read.ex index 1c6fb566..1cb112a5 100644 --- a/lib/ash/actions/read.ex +++ b/lib/ash/actions/read.ex @@ -1540,8 +1540,7 @@ defmodule Ash.Actions.Read do dep.path |> Enum.map(&elem(&1, 0)) |> Enum.concat([dep.calculation.name]) - |> Enum.map(&inspect/1) - |> Enum.join(".") + |> Enum.map_join(".", &inspect/1) query = case List.last(dep.path) do diff --git a/lib/ash/filter/filter.ex b/lib/ash/filter/filter.ex index 5b0863a4..b03c676e 100644 --- a/lib/ash/filter/filter.ex +++ b/lib/ash/filter/filter.ex @@ -7,8 +7,6 @@ defmodule Ash.Filter do alias Ash.Engine.Request alias Ash.Error.Query.{ - AggregatesNotSupported, - CalculationsNotSupported, InvalidFilterValue, NoSuchAttributeOrRelationship, NoSuchFilterPredicate, @@ -3065,37 +3063,6 @@ defmodule Ash.Filter do {:ok, val} end - defp add_aggregate_expression(context, nested_statement, field, expression) do - if context.resource && Ash.DataLayer.data_layer_can?(context.resource, :aggregate_filter) do - case parse_predicates(nested_statement, Map.get(context.aggregates, field), context) do - {:ok, nested_statement} -> - {:ok, BooleanExpression.optimized_new(:and, expression, nested_statement)} - - {:error, error} -> - {:error, error} - end - else - {:error, AggregatesNotSupported.exception(resource: context.resource, feature: "filtering")} - end - end - - defp add_calculation_expression(context, nested_statement, field, module, expression) do - if context.resource && - Ash.DataLayer.data_layer_can?(context.resource, :expression_calculation) && - :erlang.function_exported(module, :expression, 2) do - case parse_predicates(nested_statement, Map.get(context.calculations, field), context) do - {:ok, nested_statement} -> - {:ok, BooleanExpression.optimized_new(:and, expression, nested_statement)} - - {:error, error} -> - {:error, error} - end - else - {:error, - CalculationsNotSupported.exception(resource: context.resource, feature: "filtering")} - end - end - defp validate_data_layers_support_boolean_filters(%BooleanExpression{ op: :or, left: left, diff --git a/lib/ash/query/query.ex b/lib/ash/query/query.ex index 447074f0..9be1e9b6 100644 --- a/lib/ash/query/query.ex +++ b/lib/ash/query/query.ex @@ -935,7 +935,7 @@ defmodule Ash.Query do if Ash.Type.can_load?(attribute.type) do query |> Ash.Query.ensure_selected(attribute.name) - |> Ash.Query.load_through(:attributes, attribute.name, rest) + |> Ash.Query.load_through(:attribute, attribute.name, rest) else add_error( query, @@ -1007,7 +1007,7 @@ defmodule Ash.Query do end else {:error, error} -> - Ash.Query.add_error(query, :load, error) + add_error(query, :load, error) end end @@ -1132,7 +1132,7 @@ defmodule Ash.Query do ) Ash.Resource.Info.attribute(query.resource, field) -> - Ash.Query.ensure_selected(query, field) + ensure_selected(query, field) Ash.Resource.Info.relationship(query.resource, field) -> load_relationship(query, field) @@ -1147,7 +1147,7 @@ defmodule Ash.Query do {:can?, Ash.DataLayer.data_layer_can?(query.resource, {:aggregate, aggregate.kind})}, %{valid?: true} = aggregate_query <- - Ash.Query.for_read(related, read_action), + for_read(related, read_action), %{valid?: true} = aggregate_query <- build(aggregate_query, filter: aggregate.filter, sort: aggregate.sort), {:ok, query_aggregate} <- @@ -1765,13 +1765,13 @@ defmodule Ash.Query do read_action = Ash.Resource.Info.primary_action!(related, :read).name related - |> Ash.Query.for_read(read_action) + |> for_read(read_action) options when is_list(options) -> read_action = Ash.Resource.Info.primary_action!(related, :read).name related - |> Ash.Query.for_read(read_action) + |> for_read(read_action) |> build(options) %Ash.Query{} = query -> @@ -1887,7 +1887,7 @@ defmodule Ash.Query do load_resource_calculation(query, resource_calculation, args, opts[:load_through]) end else - Ash.Query.add_error(query, "No such calculation: #{inspect(calc_name)}") + add_error(query, "No such calculation: #{inspect(calc_name)}") end end @@ -2322,7 +2322,7 @@ defmodule Ash.Query do defp add_tenant_to_aggregate_query(aggregate, %{tenant: nil}), do: aggregate defp add_tenant_to_aggregate_query(%{query: nil} = aggregate, ash_query) do - aggregate_with_query = %{aggregate | query: Ash.Query.new(aggregate.resource)} + aggregate_with_query = %{aggregate | query: new(aggregate.resource)} add_tenant_to_aggregate_query(aggregate_with_query, ash_query) end