Marco
ccedbc0e46
Improve postgres documentation code ( #133 )
2023-02-25 19:57:18 -05:00
Zach Daniel
b936b812a1
chore: release version v1.3.15
2023-02-23 17:34:16 -05:00
Zach Daniel
d07083e642
improvement: add aggregates used by sorts
2023-02-21 19:45:07 -05:00
Zach Daniel
3b9377b460
chore: fix hex_api_key secret ref
2023-02-21 10:28:39 -05:00
Zach Daniel
08df325f39
chore: release version v1.3.14
2023-02-21 10:27:36 -05:00
Zach Daniel
c7e91300bb
chore: update ci to do pull requests
2023-02-21 10:27:13 -05:00
Zach Daniel
b4fa4d0d9d
chore: update ash_postgres and fix credo
2023-02-21 10:26:36 -05:00
Darren Black
587182998e
improvement: Implement string_join expr ( #132 )
2023-02-21 10:21:53 -05:00
Zach Daniel
c70fffba58
ci: add hex api key secret
2023-02-18 10:59:06 -05:00
Zach Daniel
c5579c62f0
chore: release version v1.3.13
2023-02-17 15:24:59 -05:00
Zach Daniel
49b94fd183
fix: don't use :distinct
when uniq?
is not true
2023-02-17 15:21:50 -05:00
Zach Daniel
d6ed4c6b2e
chore: release version v1.3.12
2023-02-16 16:12:52 -05:00
Zach Daniel
03f8fee3d1
fix: exclude order_by
when building aggregates
2023-02-16 16:12:28 -05:00
Zach Daniel
43c7d35085
chore: release version v1.3.11
2023-02-16 15:24:20 -05:00
Zach Daniel
67132c41bd
fix: properly find migration directories in umbrella apps
2023-02-16 15:23:50 -05:00
Zach Daniel
48488c7bad
fix: don't double-cast to array for list aggregates
2023-02-13 13:30:47 -05:00
Zach Daniel
128d8a2be8
improvement: significantly optimize aggregate queries
2023-02-12 23:18:08 -05:00
Zach Daniel
589fb4d620
improvement: better type casting for concat operator
2023-02-12 19:09:25 -05:00
Zach Daniel
8eabbde953
add tests for new transaction behavior
2023-02-10 15:41:41 -05:00
Zach Daniel
4f59b15f17
chore: release version v1.3.10
2023-02-09 17:49:52 -05:00
Zach Daniel
bbb45f3622
fix: sorting on optimized first aggregates
2023-02-09 17:49:37 -05:00
Zach Daniel
0650a76105
chore: release version v1.3.9
2023-02-09 16:10:06 -05:00
Zach Daniel
8e8a308cd2
improvement: support new uniq?
option on count/list aggregates
2023-02-09 16:09:44 -05:00
Zach Daniel
b76289f39f
docs: add AshPostgres
module to the documentation
2023-02-08 22:56:00 -05:00
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
Zach Daniel
627151afc1
chore: release version v1.3.8
2023-02-06 00:20:03 -05:00
Zach Daniel
610bfc0239
chore: update mix.lock
2023-02-06 00:19:21 -05:00
zimt28
d0bc394e36
fix: Actually use AshPostgres.Repo
behaviour ( #129 )
2023-02-05 12:46:44 -05:00
Zach Daniel
82ae1d8754
chore: update version in readme
2023-02-05 12:42:16 -05:00
Zach Daniel
93e2a786f4
improvement: authorization filters are now attached by ash core
2023-02-04 01:56:06 -05:00
Zach Daniel
7dd1681b0f
chore: release version v1.3.6
2023-02-03 11:44:49 -05:00
Zach Daniel
dc74dd534c
fix: properly set next migration name
2023-02-03 11:44:34 -05:00
Zach Daniel
cc643393d9
improvement: add migration_ignore_attributes
...
chore: update ash, fix ci
2023-02-01 02:05:04 -05:00
Zach Daniel
c3979377bd
ci: use new postgres flag in CI
2023-01-31 22:47:08 -05:00
Zach Daniel
85e6ba9598
chore: add tool-versions
2023-01-31 22:35:24 -05:00
Zach Daniel
45e88e8405
chore: use new ci
2023-01-31 22:35:12 -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
Zach Daniel
5875b68484
chore: update ash in CI and mix.lock
2023-01-30 13:45:21 -05: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
42ec9cf46a
fix: override insert
function for proper ecto interop
2023-01-29 20:27:43 -05:00
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