-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: first draft of a unit test to reproduce this type of issue: #439
wip: first draft of a unit test to reproduce this type of issue: #439
Conversation
1) test Thing.create! create works without associating other things (ThingTest) test/thing_test.exs:20 ** (Ash.Error.Unknown) Bread Crumbs: > Exception raised in: Things.get_by_id Unknown Error * ** (RuntimeError) Error while building reference: all_other_things.associated_at (ash_sql 0.2.38) lib/expr.ex:1796: AshSql.Expr.default_dynamic_expr/6 (ash_sql 0.2.38) lib/expr.ex:88: AshSql.Expr.default_dynamic_expr/6
Please address the credo & format errors 😁 |
Of course! I just thought that wasn't important until after we know if it will be merged at all 😅 |
Right right, it wasn't important just reflex sorry 🤣 |
Going to merge this and see if I can tinker with it. I've found a fix for half of the issue, specifically using these types of relationships in |
Actually maybe I fixed it all? Can you please give |
$ mix test --stale test/secret_santa/groups/group_test.exs:46 Running the above I get this very verbose error now, when running the unit tests with both
|
Mind giving |
Tests seem to pass now! So I'll just write go over them, and write some more tests, to verify that my tests are valid too! But now it compiles and seems to run ✅ |
Unfortunately, it still persists :thinkies: Commits:
I had to fix some other issues are renaming things back and forth when trying to fix this initially, and now I'm back to the same error: 10) test Groups.create! cannot read if not lead_santa and not guest (SecretSanta.Groups.GroupTest)
test/secret_santa/groups/group_test.exs:173
** (Ash.Error.Unknown)
Bread Crumbs:
> Exception raised in: SecretSanta.Groups.Group.read
> Exception raised in: SecretSanta.Groups.Group.create
Unknown Error
* ** (RuntimeError) Error while building reference: all_users.accepted_at
(ash_sql 0.2.41) lib/expr.ex:1805: AshSql.Expr.default_dynamic_expr/6
(ash_sql 0.2.41) lib/expr.ex:88: AshSql.Expr.default_dynamic_expr/6
(ash_sql 0.2.41) lib/expr.ex:75: AshSql.Expr.default_dynamic_expr/6
(ash_sql 0.2.41) lib/filter.ex:37: anonymous fn/2 in AshSql.Filter.add_filter_expression/2
(elixir 1.17.3) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash_postgres 2.4.16) lib/data_layer.ex:3014: AshPostgres.DataLayer.filter/4
(ash 3.4.46) lib/ash/query/query.ex:3119: Ash.Query.maybe_filter/3
(ash 3.4.46) lib/ash/query/query.ex:2996: Ash.Query.data_layer_query/2
(ash_sql 0.2.41) lib/join.ex:379: AshSql.Join.related_query/3
(ash_sql 0.2.41) lib/join.ex:274: AshSql.Join.related_subquery/3
(ash_sql 0.2.41) lib/aggregate.ex:171: anonymous fn/7 in AshSql.Aggregate.add_aggregates/6
(elixir 1.17.3) lib/enum.ex:4858: Enumerable.List.reduce/3
(elixir 1.17.3) lib/enum.ex:2585: Enum.reduce_while/3
(ash_sql 0.2.41) lib/aggregate.ex:88: AshSql.Aggregate.add_aggregates/6
(ash 3.4.46) lib/ash/query/query.ex:2991: Ash.Query.data_layer_query/2
(ash 3.4.46) lib/ash/actions/read/read.ex:1104: Ash.Actions.Read.reselect_and_load/6
(ash 3.4.46) lib/ash/actions/read/read.ex:310: Ash.Actions.Read.do_run/3
(ash 3.4.46) lib/ash/actions/read/read.ex:82: anonymous fn/3 in Ash.Actions.Read.run/3
(ash 3.4.46) lib/ash/actions/read/read.ex:81: Ash.Actions.Read.run/3
(ash 3.4.46) lib/ash.ex:1835: Ash.load/3 I might try to disable the policies and reintroduce them one-by-one to see. |
Is this reproduced in the repo you shared? I can take a look. |
Should be at the moment, yes: mix test test/secret_santa/groups/group_test.exs All tests fail with the same thing, since I added Otherwise it failed upon the next read with said loads. |
Alright, I've pushed something up to One thing also to keep in mind is that if worse comes to worse you can always use a manual relationship as laid out here: https://hexdocs.pm/ash_postgres/manual-relationships.html |
I don't know how valid my tests are other than that none could run due to the dynamic_expr issue 😅 But if that is fixed, I'll be able to move on and validate the rest of them. As far as I know, this is the only issue I had after trying to implement the filters. And I broke more of them by refactoring as part of figuring that out hah |
WIP of trying to reproduce an issue with many_to_many filters expressions trying to reference a parent's has_many relationship, the join-relationship.
Repository with the issue: SecretSanta Ash OpenSource
Contributor checklist