ash_postgres/test
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
..
support Update test to demo issue with policy on aggregate 2023-01-30 16:09:48 +10:00
aggregate_test.exs test: demonstrate issue loading aggregate 2023-01-31 10:35:33 +10:00
ash_postgres_test.exs chore: fix tests 2022-11-30 20:59:18 -05:00
calculation_test.exs fix: properly add aggregates to query when referenced from calculations 2022-12-18 02:23:39 -05:00
constraint_test.exs feat: add check_constraints, both for validation and migrations 2021-04-19 14:26:41 -04:00
custom_index_test.exs improvement: add unique constraints to changeset for custom unique indexes 2022-11-25 14:06:22 -05:00
distinct_test.exs fix: handle combinations of distinct & sort 2022-05-10 22:48:04 -04:00
ecto_compatibility_test.exs Add failing test for inserting via Ecto.Repo.insert! 2023-01-30 10:40:45 +10:00
embeddable_resource_test.exs test: add test confirming embedded array behavior 2022-12-18 02:35:42 -05:00
enum_test.exs improvement: support ash enums 2021-04-21 13:50:11 -04:00
filter_test.exs improvement: add like and ilike 2022-12-21 16:12:49 -05:00
load_test.exs test: add test for code interface 2022-10-31 11:53:03 -04:00
manual_relationships_test.exs fix: properly type cast top level fragments 2022-09-21 13:36:18 -04:00
migration_generator_test.exs improvement: add unique constraints to changeset for custom unique indexes 2022-11-25 14:06:22 -05:00
multitenancy_test.exs fix: properly type cast top level fragments 2022-09-21 13:36:18 -04:00
polymorphism_test.exs improvement: support calculation sorts 2021-06-05 18:13:20 -04:00
primary_key_test.exs chore: Test creating resource with uuid or integer primary key (#48) 2021-03-29 11:03:45 -04:00
schema_test.exs fix: properly type cast top level fragments 2022-09-21 13:36:18 -04:00
select_test.exs improvement: support new ash select feature 2021-04-09 00:53:50 -04:00
sort_test.exs improvement: distinct on source of query, not relationship destination 2022-12-15 17:16:53 -05:00
test_helper.exs feat: support expression based calculations 2021-06-04 01:48:35 -04:00
type_test.exs improvement: handle UUID types better 2022-10-17 08:40:32 -05:00
unique_identity_test.exs fix: support upsert_identity with base_filter 2022-07-01 19:12:14 -04:00
upsert_test.exs improvement: avg/min/max/custom aggregate support 2022-12-07 20:32:38 -05:00