ash icon indicating copy to clipboard operation
ash copied to clipboard

Complex aggregates don't pass the tenant properly

Open pshoukry opened this issue 1 year ago • 2 comments

Describe the bug count :add_somthign, [:parent, :child, child2] doesn't pass the tenant properly if it was passed ot Ash.load

or any other aggregate

IT drops the tenant on the nested resources.

To Reproduce Ash.load!(:add_somthing, tenant: tenant)

Expected behavior Should run with the poper tenant

Runtime

Additional context Add any other context about the problem here.

pshoukry avatar Oct 22 '24 17:10 pshoukry

Hey @pshoukry thanks for the report, would it be possible to provide a reproduction for this issue? Either in tests or in a reproduction project? It can be difficult to reproduce the exact scenario often, and I'm quite short on time these days.

zachdaniel avatar Oct 22 '24 23:10 zachdaniel

@zachdaniel working on that and maybe a fix if I can figure it out :)

pshoukry avatar Oct 23 '24 05:10 pshoukry

@zachdaniel the issue mainly happens on context Multi-tenancy. so if you create for example a post with comments on tenant foo

If you have aggregate count :comments_count, [:post, :comments]

and you try to Ash.load(:comments_count, tenant: "foo")

It will sporadically select the count of comments from bar. I am using Dynamic repos with tracer to connect to multiple DBs

I am trying to figure out if this can be reproduced in ash it self or ash_postgreql. but this is the better definition I have for the problem after going through the code a bit.

I am working on a fix but sorry was a bit busy wrapping something.

pshoukry avatar Nov 05 '24 07:11 pshoukry

This is better movied to ash_postgres

pshoukry avatar Nov 06 '24 20:11 pshoukry