fix: handle sensitive? option in query aggregate/calculation (#963)

This commit is contained in:
Dmitry Maganov 2024-04-01 04:28:42 +03:00 committed by GitHub
parent f885a0753f
commit bc34287edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -73,11 +73,13 @@ defmodule Ash.Query.Aggregate do
],
filterable?: [
type: :boolean,
doc: "Whether or not this aggregate may be used in filters."
doc: "Whether or not this aggregate may be used in filters.",
default: true
],
sortable?: [
type: :boolean,
doc: "Whether or not this aggregate may be used in sorts."
doc: "Whether or not this aggregate may be used in sorts.",
default: true
],
type: [
type: :any,
@ -117,7 +119,7 @@ defmodule Ash.Query.Aggregate do
sensitive?: [
type: :boolean,
doc: "Whether or not references to this aggregate will be considered sensitive",
default: true
default: false
],
authorize?: [
type: :boolean,
@ -179,8 +181,9 @@ defmodule Ash.Query.Aggregate do
relationship = opts[:path] || []
field = opts[:field]
default = opts[:default]
filterable? = Keyword.get(opts, :filterable?, true)
sortable? = Keyword.get(opts, :sortable?, true)
filterable? = opts[:filterable?]
sortable? = opts[:sortable?]
sensitive? = opts[:sensitive?]
type = opts[:type]
constraints = Keyword.get(opts, :constraints, [])
implementation = opts[:implementation]
@ -240,6 +243,7 @@ defmodule Ash.Query.Aggregate do
query: query,
filterable?: filterable?,
sortable?: sortable?,
sensitive?: sensitive?,
authorize?: authorize?,
read_action: read_action,
join_filters: Map.new(join_filters, fn {key, value} -> {List.wrap(key), value} end)

View file

@ -38,7 +38,7 @@ defmodule Ash.Query.Calculation do
sensitive?: [
type: :boolean,
doc: "Whether or not references to this calculation will be considered sensitive",
default: true
default: false
],
load: [
type: :any,
@ -86,7 +86,8 @@ defmodule Ash.Query.Calculation do
context: context,
required_loads: opts[:load],
filterable?: opts[:filterable?],
sortable?: opts[:filterable?]
sortable?: opts[:sortable?],
sensitive?: opts[:sensitive?]
}}
end
end