Zach Daniel
|
80cd06818d
|
improvement: optimized first aggregates where possible
|
2023-02-08 14:46:29 -05:00 |
|
Zach Daniel
|
8d45e92fc2
|
fix: do limit/offset outside of query if distinct is required
|
2023-02-07 19:15:44 -05:00 |
|
Zach Daniel
|
b41d383b47
|
fix: load by __order__ ascending
|
2023-02-07 17:43:53 -05:00 |
|
Alan Heywood
|
09092cc051
|
test: demonstrate issue loading aggregate
Calling Api.load! to load an aggregate on an existing record, where
the aggregated record has a relates_to_actor_via policy on it causes
the following error. Note that this error was recently fixed when
loading the aggregate as part of the query.
1) test relates to actor via has_many and with an aggregate (AshPostgres.AggregateTest)
test/aggregate_test.exs:8
** (RuntimeError) Could not determined related for `exists/2` expression.
Context Resource: %{aggregates: %{}, calculations: %{}, data_layer: AshPostgres.DataLayer, public?: false, relationship_path: [], resource: AshPostgres.Test.Comment, root_resource: AshPostgres.Test.Comment}
Context Relationship Path: []
At Path: []
Path: [:organization, :users]
Related: nil
Expression: exists(organization.users, [id: "df84db36-b8de-485b-8e47-a86307588f79"])
code: |> Api.load!(:count_of_comments, actor: user)
stacktrace:
(ash 2.5.13) lib/ash/filter/filter.ex:2121: Ash.Filter.add_expression_part/3
(ash 2.5.13) lib/ash/filter/filter.ex:2037: anonymous fn/3 in Ash.Filter.parse_expression/2
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.13) lib/ash/filter/filter.ex:295: Ash.Filter.parse/5
(ash 2.5.13) lib/ash/query/query.ex:1803: Ash.Query.do_filter/2
(elixir 1.14.2) lib/map.ex:883: Map.update!/3
(ash 2.5.13) lib/ash/engine/request.ex:654: Ash.Engine.Request.apply_filter/4
(ash 2.5.13) lib/ash/engine/request.ex:561: Ash.Engine.Request.do_strict_check/3
(ash 2.5.13) lib/ash/engine/request.ex:522: anonymous fn/2 in Ash.Engine.Request.strict_check/2
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.13) lib/ash/engine/request.ex:255: Ash.Engine.Request.do_next/1
(ash 2.5.13) lib/ash/engine/request.ex:211: Ash.Engine.Request.next/1
(ash 2.5.13) lib/ash/engine/engine.ex:650: Ash.Engine.advance_request/2
(ash 2.5.13) lib/ash/engine/engine.ex:556: Ash.Engine.fully_advance_request/2
(ash 2.5.13) lib/ash/engine/engine.ex:497: Ash.Engine.do_run_iteration/2
(elixir 1.14.2) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash 2.5.13) lib/ash/engine/engine.ex:440: Ash.Engine.run_iteration/1
(ash 2.5.13) lib/ash/engine/engine.ex:257: Ash.Engine.run_to_completion/1
(ash 2.5.13) lib/ash/engine/engine.ex:202: Ash.Engine.do_run/2
(ash 2.5.13) lib/ash/engine/engine.ex:141: Ash.Engine.run/2
(ash 2.5.13) lib/ash/actions/read.ex:170: Ash.Actions.Read.do_run/3
(ash 2.5.13) lib/ash/actions/read.ex:90: Ash.Actions.Read.run/3
(ash 2.5.13) lib/ash/api/api.ex:928: Ash.Api.load/4
(ash 2.5.13) lib/ash/api/api.ex:902: Ash.Api.load!/4
test/aggregate_test.exs:48: (test)
|
2023-01-31 10:35:33 +10:00 |
|
Alan Heywood
|
1dbd7f619d
|
Update test to demo issue with policy on aggregate
The issue occurs when an aggregate is loaded, and the aggregated
resource itself has a relates_to_actor_via policy.
The following error is produced at test/aggregate_test.exs:42
1) test relates to actor via has_many and with an aggregate (AshPostgres.AggregateTest)
test/aggregate_test.exs:8
** (RuntimeError) Could not determined related for `exists/2` expression.
Context Resource: %{aggregates: %{count_of_comments: #count<comments from #Ash.Query<resource: AshPostgres.Test.Comment>>}, calculations: %{}, data_layer: AshPostgres.DataLayer, public?: false, relationship_path: [], resource: AshPostgres.Test.Post, root_resource: AshPostgres.Test.Post}
Context Relationship Path: []
At Path: []
Path: [:post, :organization, :users]
Related: nil
Expression: exists(post.organization.users, [id: "236f08bc-6a3a-4a78-9911-2c24189dafac"])
code: |> Api.read_one!()
stacktrace:
(ash 2.5.12) lib/ash/filter/filter.ex:2121: Ash.Filter.add_expression_part/3
(ash 2.5.12) lib/ash/filter/filter.ex:2037: anonymous fn/3 in Ash.Filter.parse_expression/2
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.12) lib/ash/filter/filter.ex:295: Ash.Filter.parse/5
(ash 2.5.12) lib/ash/filter/filter.ex:995: Ash.Filter.add_to_filter/6
(ash 2.5.12) lib/ash/query/query.ex:1797: Ash.Query.do_filter/2
(elixir 1.14.2) lib/map.ex:883: Map.update!/3
(ash 2.5.12) lib/ash/engine/request.ex:650: Ash.Engine.Request.apply_filter/4
(ash 2.5.12) lib/ash/engine/request.ex:557: Ash.Engine.Request.do_strict_check/3
(ash 2.5.12) lib/ash/engine/request.ex:518: anonymous fn/2 in Ash.Engine.Request.strict_check/2
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.12) lib/ash/engine/request.ex:255: Ash.Engine.Request.do_next/1
(ash 2.5.12) lib/ash/engine/request.ex:211: Ash.Engine.Request.next/1
(ash 2.5.12) lib/ash/engine/engine.ex:650: Ash.Engine.advance_request/2
(ash 2.5.12) lib/ash/engine/engine.ex:556: Ash.Engine.fully_advance_request/2
(ash 2.5.12) lib/ash/engine/engine.ex:497: Ash.Engine.do_run_iteration/2
(elixir 1.14.2) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash 2.5.12) lib/ash/engine/engine.ex:257: Ash.Engine.run_to_completion/1
(ash 2.5.12) lib/ash/engine/engine.ex:202: Ash.Engine.do_run/2
(ash 2.5.12) lib/ash/engine/engine.ex:141: Ash.Engine.run/2
(ash 2.5.12) lib/ash/actions/read.ex:170: Ash.Actions.Read.do_run/3
(ash 2.5.12) lib/ash/actions/read.ex:90: Ash.Actions.Read.run/3
(ash 2.5.12) lib/ash/api/api.ex:1005: Ash.Api.read_one/3
(ash 2.5.12) lib/ash/api/api.ex:998: Ash.Api.read_one!/3
test/aggregate_test.exs:43: (test)
|
2023-01-30 16:09:48 +10:00 |
|
Zach Daniel
|
04a64b8b94
|
chore: credo
|
2023-01-29 18:24:11 -05:00 |
|
Alan Heywood
|
f290ae47b8
|
Add failing test for policy + aggregate issue
The conditions for this issue to occur seem to be:
- DataLayer is Postgres
- Resource has a relates_to_actor_via policy on read
- The relates_to_actor_via path includes a has_many relationship
- An aggregate is loaded
The following error is produced:
1) test relates to actor via has_many and with an aggregate (AshPostgres.AggregateTest)
test/aggregate_test.exs:8
** (Ash.Error.Unknown.UnknownError) ** (ArgumentError) No such entity nil found.
code: |> Api.read_one!(actor: user)
stacktrace:
nil.spark_dsl_config()
(spark 0.3.8) lib/spark/dsl/extension.ex:129: Spark.Dsl.Extension.dsl!/1
(spark 0.3.8) lib/spark/dsl/extension.ex:158: Spark.Dsl.Extension.get_persisted/3
(ash 2.5.10) lib/ash/filter/filter.ex:2986: Ash.Filter.do_hydrate_refs/2
(ash 2.5.10) lib/ash/policy/check/relates_to_actor_via.ex:3: Ash.Policy.Check.RelatesToActorVia.try_eval/2
(ash 2.5.10) lib/ash/policy/check/relates_to_actor_via.ex:3: Ash.Policy.Check.RelatesToActorVia.try_strict_check/3
(ash 2.5.10) lib/ash/policy/checker.ex:63: Ash.Policy.Checker.do_strict_check_facts/3
(ash 2.5.10) lib/ash/policy/checker.ex:88: anonymous fn/2 in Ash.Policy.Checker.strict_check_policies/3
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.10) lib/ash/policy/checker.ex:9: anonymous fn/2 in Ash.Policy.Checker.strict_check_facts/1
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.10) lib/ash/policy/authorizer.ex:790: Ash.Policy.Authorizer.do_strict_check_facts/1
(ash 2.5.10) lib/ash/policy/authorizer.ex:372: Ash.Policy.Authorizer.strict_check/2
(ash 2.5.10) lib/ash/engine/request.ex:550: Ash.Engine.Request.do_strict_check/3
(ash 2.5.10) lib/ash/engine/request.ex:518: anonymous fn/2 in Ash.Engine.Request.strict_check/2
(elixir 1.14.2) lib/enum.ex:4751: Enumerable.List.reduce/3
(elixir 1.14.2) lib/enum.ex:2514: Enum.reduce_while/3
(ash 2.5.10) lib/ash/engine/request.ex:255: Ash.Engine.Request.do_next/1
(ash 2.5.10) lib/ash/engine/request.ex:211: Ash.Engine.Request.next/1
(ash 2.5.10) lib/ash/engine/engine.ex:650: Ash.Engine.advance_request/2
(ash 2.5.10) lib/ash/engine/engine.ex:556: Ash.Engine.fully_advance_request/2
(ash 2.5.10) lib/ash/engine/engine.ex:497: Ash.Engine.do_run_iteration/2
(elixir 1.14.2) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash 2.5.10) lib/ash/engine/engine.ex:440: Ash.Engine.run_iteration/1
(ash 2.5.10) lib/ash/engine/engine.ex:257: Ash.Engine.run_to_completion/1
(ash 2.5.10) lib/ash/engine/engine.ex:202: Ash.Engine.do_run/2
(ash 2.5.10) lib/ash/engine/engine.ex:141: Ash.Engine.run/2
(ash 2.5.10) lib/ash/actions/read.ex:170: Ash.Actions.Read.do_run/3
(ash 2.5.10) lib/ash/actions/read.ex:90: Ash.Actions.Read.run/3
(ash 2.5.10) lib/ash/api/api.ex:1005: Ash.Api.read_one/3
(ash 2.5.10) lib/ash/api/api.ex:998: Ash.Api.read_one!/3
test/aggregate_test.exs:44: (test)
|
2023-01-29 16:15:16 +10:00 |
|
Zach Daniel
|
3c496512e2
|
fix: use parent_expr instead of this
fix: various expression & type building fixes
|
2023-01-06 17:05:23 -05:00 |
|
Zach Daniel
|
e81e77840a
|
fix: don't group aggregates that reference relationships in their filters
|
2022-12-21 16:58:12 -05:00 |
|
Zach Daniel
|
e271a27d3c
|
improvement: avg/min/max/custom aggregate support
fix: fix various problems with the model behind aggregates
|
2022-12-07 20:32:38 -05:00 |
|
Zach Daniel
|
52fcba79ac
|
improvement: inform users about postgres incompatibility with multidimensional arrays
|
2022-12-01 20:24:49 -05:00 |
|
Darren Black
|
f088601cf9
|
Failing tests for aggregates on arrays (#121)
|
2022-11-30 21:26:58 -05:00 |
|
Zach Daniel
|
fd5ac60072
|
improvement: exists filters necessitate multiple aggregate joins (for now)
|
2022-09-28 18:01:20 -04:00 |
|
Zach Daniel
|
e8643d4aa0
|
fix: properly type cast top level fragments
chore: update tests not to use deprecated helper
|
2022-09-21 13:36:18 -04:00 |
|
Zach Daniel
|
4a69edce2d
|
important: update to ash 2.0 branch
|
2022-08-24 12:07:38 -04:00 |
|
Zach Daniel
|
c352a1f1fa
|
fix: support upsert_identity with base_filter
|
2022-07-01 19:12:14 -04:00 |
|
Zach Daniel
|
da07ed7b6c
|
fix: handle various join bugs
|
2022-06-29 15:08:49 -04:00 |
|
kernel-io
|
7675191172
|
failing custom aggregate test (#82)
Co-authored-by: kernel-io <kernel>
Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
|
2022-03-09 19:45:06 -05:00 |
|
Zach Daniel
|
efaa7c6cc6
|
fix: properly handle relationship filter bindings
fix: don't consider fields changed with only source -> name changes
|
2022-02-14 17:44:17 -05:00 |
|
Zach Daniel
|
e6ff1d8b4b
|
fix: fix aggregate/base filters
|
2022-02-11 16:06:51 -05:00 |
|
Zach Daniel
|
cd9701a6ea
|
improvement: support referencing aggregates from aggregate filters
fix: don't select more fields than necessary
|
2022-02-09 11:49:19 -05:00 |
|
Zach Daniel
|
5b88f476f2
|
chore: remove empty test
|
2021-12-17 13:25:45 -05:00 |
|
Zach Daniel
|
2fdcea7ef8
|
improvement: support default on aggregates
chore: update to latest ash patterns for testing
|
2021-10-25 18:53:34 -04:00 |
|
Zach Daniel
|
be7e2a89bc
|
fix: left_lateral_join for many_to_many aggregates
fix: properly reference nested aggregate fields for join
fix: properly determine fallback table for polymorphic resources
|
2021-07-05 14:12:21 -04:00 |
|
Zach Daniel
|
f13f31330f
|
fix: properly set aggregate query sources
|
2021-07-02 12:41:44 -04:00 |
|
Zach Daniel
|
f0b901173c
|
fix: properly group many_to_many aggregates
|
2021-05-12 13:17:26 -04:00 |
|
Zach Daniel
|
7911de61a5
|
improvement: support latest ash/filtering on related aggregates
|
2021-05-08 23:25:28 -04:00 |
|
Zach Daniel
|
29956794ff
|
improvement: update to latest ash
chore: add aggregate test
chore: small experimental interface change
|
2021-05-06 17:37:29 -04:00 |
|
Zach Daniel
|
1cce277e7d
|
improvement: support list aggregate
|
2021-04-26 16:45:47 -04:00 |
|
Michael St Clair
|
cf92fe14a5
|
improvement: add sum aggregate (#53)
|
2021-04-04 16:05:41 -04:00 |
|
Zach Daniel
|
b2428213c7
|
feat: support latest Ash version
|
2020-12-28 19:26:04 -05:00 |
|