Commit graph

757 commits

Author SHA1 Message Date
Alan Heywood
acc947292d Add failing test for inserting via Ecto.Repo.insert!
It should be possible to use this function, and it did work as of ash
v2.5.9. This test fails as of ash v2.5.10, which introduced adding
relationships to underlying ecto schemas. The bug is related to a
has_many relationship being present on the resource.

The test fails with:

1) test call Ecto.Repo.insert! via Ash Repo (AshPostgres.EctoCompatibilityTest)
     test/ecto_compatibility_test.exs:6
     ** (Ecto.InvalidChangesetError) could not perform insert because changeset is invalid.

     Errors

         %{posts: [{"is invalid", [type: {:array, :map}]}]}

     Applied changes

         %{name: "The Org"}

     Params

         nil

     Changeset

         #Ecto.Changeset<
           action: :insert,
           changes: %{name: "The Org"},
           errors: [posts: {"is invalid", [type: {:array, :map}]}],
           data: #AshPostgres.Test.Organization<>,
           valid?: false
         >

     code: |> AshPostgres.TestRepo.insert!()
     stacktrace:
       (ecto 3.9.4) lib/ecto/repo/schema.ex:270: Ecto.Repo.Schema.insert!/4
       test/ecto_compatibility_test.exs:9: (test)
2023-01-30 10:40:45 +10:00
Zach Daniel
568fdb3330 ci: update ash version in CI 2023-01-29 18:43:57 -05:00
Zach Daniel
14d1f04a24 chore: update ash to latest version 2023-01-29 18:42:40 -05:00
Zach Daniel
4ee02a03b1 chore: release version v1.3.5 2023-01-29 18:24:19 -05:00
Zach Daniel
04a64b8b94 chore: credo 2023-01-29 18:24:11 -05:00
Zach Daniel
b52da94b32 fix: properly convert to/from ecto, only when necessary 2023-01-29 18:20:59 -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
613e06c2d6 chore: release version v1.3.4 2023-01-27 20:54:52 -05:00
Zach Daniel
ce3cb0f2df fix: support latest ecto interop changes in ash core 2023-01-27 20:54:40 -05:00
Zach Daniel
49c55eaac4 improvement: properly cast division to floats for elixir-y behavior 2023-01-26 23:48:19 -05:00
Zach Daniel
492d8e88e9 docs: add a comment about config added earlier 2023-01-25 10:15:01 -05:00
Zach Daniel
a9d46e0163 improvement: support for dynamically set repo 2023-01-19 09:33:19 -05:00
Zach Daniel
2c788ddb06 improvement: update ash 2023-01-18 01:05:28 -05:00
Zach Daniel
c9abef6e2c chore: remove doc index 2023-01-18 01:00:23 -05:00
Zach Daniel
0dc741041f chore: release version v1.3.3 2023-01-18 00:53:39 -05:00
Zach Daniel
ec2ccedeb6 improvement: update to new docs patterns 2023-01-18 00:53:21 -05:00
Zach Daniel
7bf4cf80b1 chore: release version v1.3.2 2023-01-17 09:58:14 -05:00
Zach Daniel
ee97fde9dc fix: nest subqueries when required for distinct
fix: replace `{:in, ...}` type with `{:array, ...}`
2023-01-17 09:57:05 -05:00
Zach Daniel
0d52f27011 ci: upgrade beam versions 2023-01-11 08:10:54 -05:00
Zach Daniel
a9fec8bfa4 ci: update ash version in CI 2023-01-11 07:53:47 -05:00
Zach Daniel
954638f67f chore: release version v1.3.1 2023-01-11 07:53:33 -05:00
Zach Daniel
91f9d9b9b2 fix: allow for non attribute aggregate references for first/list 2023-01-11 07:51:12 -05:00
Zach Daniel
0a6940eee4 chore: release version v1.3.0 2023-01-10 21:55:20 -05:00
Zach Daniel
a3577479e3 improvement: update to latest ash 2023-01-10 21:54:28 -05:00
Zach Daniel
41bfff4bf8 chore: release version v1.3.0-rc.4 2023-01-09 13:56:23 -05:00
Zach Daniel
79f84041ae fix: properly join to all required relationships 2023-01-09 13:56:05 -05:00
Zach Daniel
d4ad6ce989 ci: fix build 2023-01-09 11:10:01 -05:00
Zach Daniel
e61fd377fe chore: release version v1.3.0-rc.3 2023-01-09 10:41:46 -05:00
Zach Daniel
1aab3dd7e3 fix: properly type cast in fragments (and elsewhere) 2023-01-09 09:48:25 -05:00
Zach Daniel
9428f68ccf chore: release version v1.3.0-rc.2 2023-01-06 17:46:38 -05:00
Zach Daniel
7ee60c76b1 chore: release version v1.3.0-rc.1 2023-01-06 17:46:23 -05:00
Zach Daniel
c15a6e4613 fix: undo changes that caused type casting bugs 2023-01-06 17:45:10 -05:00
Zach Daniel
f65c936a54 chore: release version v1.3.0-rc.1 2023-01-06 17:06:10 -05: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
3e75d562ec chore: release version v1.3.0-rc.0 2023-01-04 12:36:35 -05:00
Zach Daniel
475ec0f1ca feat: support latest ash 2023-01-04 12:36:18 -05:00
Zach Daniel
7f3f02fc44 chore: optimize binding calculation 2022-12-31 09:22:12 -05:00
Zach Daniel
5a7f42fac1 improvement: support calc constraints 2022-12-28 23:11:55 -05:00
Zach Daniel
301962cbb1 fix: honor calculation constraints 2022-12-28 23:01:19 -05:00
Zach Daniel
87617f8d97 improvement: support new cast_in_query?/2 2022-12-28 22:41:32 -05:00
Zach Daniel
301466e1b5 improvement: support calculations as aggregate targets
fix: handle lists with expressions inside
2022-12-28 22:08:07 -05:00
Zach Daniel
c1bf5b5eec chore: release version v1.2.6 2022-12-27 18:19:36 -05:00
Zach Daniel
4f91e65d51 fix: properly set migrations_path default in umbrellas 2022-12-27 18:19:18 -05:00
Zach Daniel
eac649e5fb fix: don't subquery unless we have to 2022-12-21 23:59:27 -05:00
Zach Daniel
bb96d64ac0 chore: release version v1.2.5 2022-12-21 16:58:32 -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
09b19c8bfd improvement: add like and ilike 2022-12-21 16:12:49 -05:00
Zach Daniel
5a9abdc69c fix: properly skip unique indexes when configured 2022-12-21 02:16:30 -05:00
Zach Daniel
01d1a8aa5d test: add test confirming embedded array behavior 2022-12-18 02:35:42 -05:00
Zach Daniel
360274c7c0 chore: release version v1.2.4 2022-12-18 02:24:31 -05:00