Skip to content

Commit

Permalink
fix: pass actor through from source_context when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Nov 5, 2024
1 parent 5cb05d4 commit 3fea900
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/ash/query/calculation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ defmodule Ash.Query.Calculation do
hide: true,
doc: "A resource calculation this calculation maps to."
],
actor: [
type: :any,
doc: "The actor performing the calculation."
],
tenant: [
type: :any,
doc: "The tenant performing the calculation."
],
tracer: [
type: :any,
doc: "The tracer or tracers used in the calculation."
],
source_context: [
type: :map,
doc: "Context from the source query or changeset.",
Expand Down Expand Up @@ -90,6 +102,9 @@ defmodule Ash.Query.Calculation do
arguments: opts.arguments,
type: type,
constraints: constraints,
actor: opts.actor || opts.source_context[:private][:actor],
tenant: opts.tenant || opts.source_context[:private][:tenant],
tracer: opts.tracer || opts.source_context[:private][:tracer],
source_context: opts.source_context
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ash/query/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ defmodule Ash.Query do
end

with {:ok, calculation} <-
Ash.Query.Calculation.from_resource_calculation!(query.resource, resource_calculation,
Ash.Query.Calculation.from_resource_calculation(query.resource, resource_calculation,
source_context: query.context,
args: Map.new(args)
) do
Expand Down

0 comments on commit 3fea900

Please sign in to comment.