ash_postgres/test/complex_calculations_test.exs

304 lines
8.4 KiB
Elixir
Raw Normal View History

test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
defmodule AshPostgres.Test.ComplexCalculationsTest do
use AshPostgres.RepoCase, async: false
require Ash.Query
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
test "complex calculation" do
certification =
AshPostgres.Test.ComplexCalculations.Certification
|> Ash.Changeset.new()
|> Ash.create!()
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
skill =
AshPostgres.Test.ComplexCalculations.Skill
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:certification, certification, type: :append)
|> Ash.create!()
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
_documentation =
AshPostgres.Test.ComplexCalculations.Documentation
|> Ash.Changeset.for_create(:create, %{status: :demonstrated})
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
|> Ash.Changeset.manage_relationship(:skill, skill, type: :append)
|> Ash.create!()
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
skill =
skill
|> Ash.load!([:latest_documentation_status])
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
assert skill.latest_documentation_status == :demonstrated
certification =
certification
|> Ash.load!([
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
:count_of_skills
])
assert certification.count_of_skills == 1
certification =
certification
|> Ash.load!([
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
:count_of_approved_skills
])
assert certification.count_of_approved_skills == 0
certification =
certification
|> Ash.load!([
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
:count_of_documented_skills
])
assert certification.count_of_documented_skills == 1
certification =
certification
|> Ash.load!([
:count_of_documented_skills,
:all_documentation_approved,
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
:some_documentation_created
])
assert certification.some_documentation_created
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
end
test: add failing test to demonstrate an error with nested aggregates (#295) 1) test complex aggregates (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:66 ** (Ash.Error.Unknown) Unknown Error * ** (Ecto.SubQueryError) the following exception happened when compiling a subquery. ** (Ecto.SubQueryError) the following exception happened when compiling a subquery. ** (Ecto.QueryError) could not find named binding `parent_as(false)` in query: from c0 in AshPostgres.Test.ComplexCalculations.Certification, as: 0, left_lateral_join: s1 in subquery(from s0 in AshPostgres.Test.ComplexCalculations.Skill, as: 0, left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation, as: 0, where: parent_as(false).id == as(0).skill_id, where: type( as(0).status, {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ) == type( ^"demonstrated", {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ), group_by: [d0.skill_id], select: %{ skill_id: map(d0, [:skill_id]).skill_id, count_of_demonstrated_documentations: type( coalesce( count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})), type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), on: true, where: parent_as(0).id == as(0).certification_id, where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) == type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}), group_by: [s0.certification_id], select: %{ certification_id: map(s0, [:certification_id]).certification_id, count_of_skills_ever_demonstrated: type( sum( type( fragment( "(CASE WHEN ? THEN ? ELSE ? END)", type( coalesce( as(1).count_of_demonstrated_documentations, type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) == type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}), type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}), type(^1, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), on: true, where: type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []}) == type(^"e24ef8a5-d39d-4293-9f69-1abd10a996e6", {:parameterized, Ash.Type.UUID.EctoType, []}), select: merge( merge(struct(c0, [:id]), %{ count_of_skills_ever_demonstrated: type( type( s1.count_of_skills_ever_demonstrated, {:parameterized, Ash.Type.Integer.EctoType, []} ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), %{} ) The subquery originated from the following query: from s0 in AshPostgres.Test.ComplexCalculations.Skill, as: 0, left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation, as: 0, where: parent_as(false).id == as(0).skill_id, where: type( as(0).status, {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ) == type( ^"demonstrated", {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ), group_by: [d0.skill_id], select: %{ skill_id: map(d0, [:skill_id]).skill_id, count_of_demonstrated_documentations: type( coalesce( count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})), type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), on: true, where: parent_as(0).id == as(0).certification_id, where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) == type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}), group_by: [s0.certification_id], select: %{ certification_id: map(s0, [:certification_id]).certification_id, count_of_skills_ever_demonstrated: type( sum( type( fragment( "(CASE WHEN ? THEN ? ELSE ? END)", type( coalesce( d1.count_of_demonstrated_documentations, type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) == type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}), type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}), type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) } The subquery originated from the following query: from c0 in AshPostgres.Test.ComplexCalculations.Certification, as: 0, left_lateral_join: s1 in subquery(from s0 in AshPostgres.Test.ComplexCalculations.Skill, as: 0, left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation, as: 0, where: parent_as(false).id == as(0).skill_id, where: type( as(0).status, {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ) == type( ^"demonstrated", {:parameterized, Ash.Type.Atom.EctoType, one_of: [:demonstrated, :performed, :approved, :reopened]} ), group_by: [d0.skill_id], select: %{ skill_id: map(d0, [:skill_id]).skill_id, count_of_demonstrated_documentations: type( coalesce( count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})), type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), on: true, where: parent_as(0).id == as(0).certification_id, where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) == type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}), group_by: [s0.certification_id], select: %{ certification_id: map(s0, [:certification_id]).certification_id, count_of_skills_ever_demonstrated: type( sum( type( fragment( "(CASE WHEN ? THEN ? ELSE ? END)", type( coalesce( as(1).count_of_demonstrated_documentations, type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) == type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}), type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}), type(^1, {:parameterized, Ash.Type.Integer.EctoType, []}) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), on: true, where: type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []}) == type(^"e24ef8a5-d39d-4293-9f69-1abd10a996e6", {:parameterized, Ash.Type.UUID.EctoType, []}), select: merge( merge(struct(c0, [:id]), %{ count_of_skills_ever_demonstrated: type( type( s1.count_of_skills_ever_demonstrated, {:parameterized, Ash.Type.Integer.EctoType, []} ), {:parameterized, Ash.Type.Integer.EctoType, []} ) }), %{} ) (elixir 1.16.2) lib/enum.ex:1826: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3 (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3 (ecto 3.11.2) lib/ecto/repo/queryable.ex:214: Ecto.Repo.Queryable.execute/4 (ecto 3.11.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3 (ash_postgres 2.0.2) lib/data_layer.ex:706: anonymous fn/3 in AshPostgres.DataLayer.run_query/2 (ash_postgres 2.0.2) lib/data_layer.ex:704: AshPostgres.DataLayer.run_query/2 (ash 3.0.2) lib/ash/actions/read/read.ex:2259: Ash.Actions.Read.run_query/4 (ash 3.0.2) lib/ash/actions/read/read.ex:903: Ash.Actions.Read.reselect_and_load/5 (ash 3.0.2) lib/ash/actions/read/read.ex:244: Ash.Actions.Read.do_run/3 (ash 3.0.2) lib/ash/actions/read/read.ex:66: anonymous fn/3 in Ash.Actions.Read.run/3 (ash 3.0.2) lib/ash/actions/read/read.ex:65: Ash.Actions.Read.run/3 (ash 3.0.2) lib/ash.ex:1717: Ash.load/3 (ash 3.0.2) lib/ash.ex:1687: Ash.load/3 (ash 3.0.2) lib/ash.ex:1635: Ash.load!/3 test/complex_calculations_test.exs:85: AshPostgres.Test.ComplexCalculationsTest."test complex aggregates"/1 (ex_unit 1.16.2) lib/ex_unit/runner.ex:472: ExUnit.Runner.exec_test/2 (stdlib 5.2) timer.erl:270: :timer.tc/2 (ex_unit 1.16.2) lib/ex_unit/runner.ex:394: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4 code: |> Ash.load!([:count_of_skills_ever_demonstrated]) stacktrace: (elixir 1.16.2) lib/process.ex:860: Process.info/2 (ash 3.0.2) lib/ash/error/unknown.ex:3: Ash.Error.Unknown."exception (overridable 2)"/1 (ash 3.0.2) ash_postgres/deps/splode/lib/splode.ex:211: Ash.Error.to_class/2 (ash 3.0.2) lib/ash/error/error.ex:66: Ash.Error.to_error_class/2 (ash 3.0.2) lib/ash/actions/read/read.ex:324: Ash.Actions.Read.do_run/3 (ash 3.0.2) lib/ash/actions/read/read.ex:66: anonymous fn/3 in Ash.Actions.Read.run/3 (ash 3.0.2) lib/ash/actions/read/read.ex:65: Ash.Actions.Read.run/3 (ash 3.0.2) lib/ash.ex:1717: Ash.load/3 (ash 3.0.2) lib/ash.ex:1687: Ash.load/3 (ash 3.0.2) lib/ash.ex:1635: Ash.load!/3 test/complex_calculations_test.exs:85: (test)
2024-05-21 14:42:44 +12:00
test "complex aggregates" do
certification =
AshPostgres.Test.ComplexCalculations.Certification
|> Ash.Changeset.new()
|> Ash.create!()
skill =
AshPostgres.Test.ComplexCalculations.Skill
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:certification, certification, type: :append)
|> Ash.create!()
AshPostgres.Test.ComplexCalculations.Documentation
|> Ash.Changeset.for_create(:create, %{status: :demonstrated})
|> Ash.Changeset.manage_relationship(:skill, skill, type: :append)
|> Ash.create!()
certification =
certification
|> Ash.load!([:count_of_skills_ever_demonstrated])
assert certification.count_of_skills_ever_demonstrated == 1
end
test "channel: first_member and second member" do
channel =
AshPostgres.Test.ComplexCalculations.Channel
|> Ash.Changeset.new()
|> Ash.create!()
user_1 =
AshPostgres.Test.User
|> Ash.Changeset.for_create(:create, %{name: "User 1"})
|> Ash.create!()
user_2 =
AshPostgres.Test.User
|> Ash.Changeset.for_create(:create, %{name: "User 2"})
|> Ash.create!()
channel_member_1 =
AshPostgres.Test.ComplexCalculations.ChannelMember
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:channel, channel, type: :append)
|> Ash.Changeset.manage_relationship(:user, user_1, type: :append)
|> Ash.create!()
channel_member_2 =
AshPostgres.Test.ComplexCalculations.ChannelMember
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:channel, channel, type: :append)
|> Ash.Changeset.manage_relationship(:user, user_2, type: :append)
|> Ash.create!()
channel =
channel
|> Ash.load!([
:first_member,
:second_member
])
assert channel.first_member.id == channel_member_1.id
assert channel.second_member.id == channel_member_2.id
channel =
channel
|> Ash.load!(:name, actor: user_1)
assert channel.name == user_1.name
channel =
channel
|> Ash.load!(:name, actor: user_2)
assert channel.name == user_2.name
end
test "complex calculation while using actor on related resource passes reference" do
dm_channel =
AshPostgres.Test.ComplexCalculations.DMChannel
|> Ash.Changeset.new()
|> Ash.create!()
user_1 =
AshPostgres.Test.User
|> Ash.Changeset.for_create(:create, %{name: "User 1"})
|> Ash.create!()
user_2 =
AshPostgres.Test.User
|> Ash.Changeset.for_create(:create, %{name: "User 2"})
|> Ash.create!()
channel_member_1 =
AshPostgres.Test.ComplexCalculations.ChannelMember
|> Ash.Changeset.for_create(:create, %{channel_id: dm_channel.id, user_id: user_1.id})
|> Ash.create!()
channel_member_2 =
AshPostgres.Test.ComplexCalculations.ChannelMember
|> Ash.Changeset.for_create(:create, %{channel_id: dm_channel.id, user_id: user_2.id})
|> Ash.create!()
dm_channel =
dm_channel
|> Ash.load!([
:first_member,
:second_member
])
assert dm_channel.first_member.id == channel_member_1.id
assert dm_channel.second_member.id == channel_member_2.id
dm_channel =
dm_channel
|> Ash.load!(:name, actor: user_1)
assert dm_channel.name == user_1.name
dm_channel =
dm_channel
|> Ash.load!(:name, actor: user_2)
assert dm_channel.name == user_2.name
channels =
AshPostgres.Test.ComplexCalculations.Channel
|> Ash.Query.for_read(:read)
|> Ash.read!()
channels =
channels
|> Ash.load!([dm_channel: :name],
actor: user_1
)
[channel | _] = channels
assert channel.dm_channel.name == user_1.name
channel =
channel
|> Ash.load!([:dm_name, :foo], actor: user_2)
assert channel.dm_name == user_2.name
end
test "calculations with parent filters can be filtered on themselves" do
AshPostgres.Test.ComplexCalculations.DMChannel
|> Ash.Changeset.new()
|> Ash.create!()
assert [%{foo: "foobar"}] =
AshPostgres.Test.ComplexCalculations.Channel
|> Ash.Query.filter(foo == "foobar")
|> Ash.read!(load: :foo)
end
test "calculations with aggregates can be referenced from aggregates" do
author =
AshPostgres.Test.Author
|> Ash.Changeset.for_create(:create, %{first_name: "is", last_name: "match"})
|> Ash.create!()
AshPostgres.Test.Post
|> Ash.Changeset.for_create(:create, %{title: "match"})
|> Ash.Changeset.manage_relationship(:author, author, type: :append_and_remove)
|> Ash.create!()
assert [%{author_count_of_posts: 1}] =
AshPostgres.Test.Post
|> Ash.Query.load(:author_count_of_posts)
|> Ash.read!()
assert [%{author_count_of_posts: 1}] =
AshPostgres.Test.Post
|> Ash.read!()
|> Ash.load!(:author_count_of_posts)
assert [_] =
AshPostgres.Test.Post
|> Ash.Query.filter(author_count_of_posts == 1)
|> Ash.read!()
end
test "calculations can reference aggregates from optimizable first aggregates" do
author =
AshPostgres.Test.Author
|> Ash.Changeset.for_create(:create, %{first_name: "is", last_name: "match"})
|> Ash.create!()
AshPostgres.Test.Post
|> Ash.Changeset.for_create(:create, %{title: "match"})
|> Ash.Changeset.manage_relationship(:author, author, type: :append_and_remove)
|> Ash.create!()
assert [%{author_count_of_posts_agg: 1}] =
AshPostgres.Test.Post
|> Ash.Query.load(:author_count_of_posts_agg)
|> Ash.read!()
assert [%{author_count_of_posts_agg: 1}] =
AshPostgres.Test.Post
|> Ash.read!()
|> Ash.load!(:author_count_of_posts_agg)
assert [_] =
AshPostgres.Test.Post
|> Ash.Query.filter(author_count_of_posts_agg == 1)
|> Ash.read!()
end
test "calculations can reference aggregates from non optimizable aggregates" do
author =
AshPostgres.Test.Author
|> Ash.Changeset.for_create(:create, %{first_name: "is", last_name: "match"})
|> Ash.create!()
AshPostgres.Test.Post
|> Ash.Changeset.for_create(:create, %{title: "match"})
|> Ash.Changeset.manage_relationship(:author, author, type: :append_and_remove)
|> Ash.create!()
assert [%{sum_of_author_count_of_posts: 1}] =
AshPostgres.Test.Post
|> Ash.Query.load(:sum_of_author_count_of_posts)
|> Ash.read!()
assert [%{sum_of_author_count_of_posts: 1}] =
AshPostgres.Test.Post
|> Ash.read!()
|> Ash.load!(:sum_of_author_count_of_posts)
assert [_] =
AshPostgres.Test.Post
|> Ash.Query.filter(sum_of_author_count_of_posts == 1)
|> Ash.read!()
end
test: add failing test to demonstrate potential bug (#164) 1) test complex calculation (AshPostgres.Test.ComplexCalculationsTest) test/complex_calculations_test.exs:5 ** (RuntimeError) Error while building reference: latest_documentation_status code: |> AshPostgres.Test.ComplexCalculations.Api.load!([ stacktrace: (ash_postgres 1.3.41) lib/expr.ex:846: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:109: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:356: AshPostgres.Expr.do_dynamic_expr/5 (ash_postgres 1.3.41) lib/expr.ex:968: anonymous fn/6 in AshPostgres.Expr.do_dynamic_expr/5 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:76: Ecto.Query.Builder.Dynamic.expand/3 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (stdlib 5.0.2) lists.erl:1707: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (stdlib 5.0.2) lists.erl:1706: :lists.mapfoldl_1/3 (elixir 1.15.4) lib/macro.ex:653: Macro.do_traverse/4 (ecto 3.10.3) lib/ecto/query/builder/dynamic.ex:59: Ecto.Query.Builder.Dynamic.partially_expand/6 (ecto 3.10.3) lib/ecto/query/builder/select.ex:235: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:274: Ecto.Query.Builder.Select.expand_nested_pair/3 (elixir 1.15.4) lib/enum.ex:1825: anonymous fn/3 in Enum.map_reduce/3 (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4 (elixir 1.15.4) lib/enum.ex:2522: Enum.map_reduce/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:257: Ecto.Query.Builder.Select.expand_nested/3 (ecto 3.10.3) lib/ecto/query/builder/select.ex:205: Ecto.Query.Builder.Select.select!/5 (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 (ash_postgres 1.3.41) lib/aggregate.ex:121: anonymous fn/6 in AshPostgres.Aggregate.add_aggregates/6 (elixir 1.15.4) lib/enum.ex:4830: Enumerable.List.reduce/3 (elixir 1.15.4) lib/enum.ex:2564: Enum.reduce_while/3 (ash_postgres 1.3.41) lib/aggregate.ex:53: AshPostgres.Aggregate.add_aggregates/6 (ash 2.13.3) lib/ash/query/aggregate.ex:570: anonymous fn/6 in Ash.Query.Aggregate.value_request/9 (ash 2.13.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1 (ash 2.13.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2 (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.15.4) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 2.13.3) lib/ash/engine/engine.ex:552: Ash.Engine.async/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ash 2.13.3) lib/ash/engine/engine.ex:702: Ash.Engine.start_pending_tasks/1 (ash 2.13.3) lib/ash/engine/engine.ex:323: Ash.Engine.run_to_completion/1 (ash 2.13.3) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2 (ash 2.13.3) lib/ash/engine/engine.ex:148: Ash.Engine.run/2 (ash 2.13.3) lib/ash/actions/read.ex:173: Ash.Actions.Read.do_run/3 (ash 2.13.3) lib/ash/actions/read.ex:96: Ash.Actions.Read.run/3 (ash 2.13.3) lib/ash/api/api.ex:1733: Ash.Api.load/4 (ash 2.13.3) lib/ash/api/api.ex:1707: Ash.Api.load!/4 test/complex_calculations_test.exs:55: (test)
2023-08-17 12:49:18 +12:00
end