Problem with load of User

I my user, I have the following relationship
elixir
has_many :organizations, CauseBeacon.Organizations.Organization do
no_attributes? true

filter expr(
(admin_members.user_id == parent(id) and admin_members.status == :accepted) or
(members.user_id == parent(id) and members.status == :activated)
)

sort "admin_members.default": :asc, "admin_members.inserted_at": :desc
end
elixir
has_many :organizations, CauseBeacon.Organizations.Organization do
no_attributes? true

filter expr(
(admin_members.user_id == parent(id) and admin_members.status == :accepted) or
(members.user_id == parent(id) and members.status == :activated)
)

sort "admin_members.default": :asc, "admin_members.inserted_at": :desc
end
in my Plug to load User, I have
elixir
def call(%{assigns: %{current_user: %{} = current_user}} = conn, _ops) do
loaded_user =
Ash.load!(
current_user,
[:display_name, :full_name, :organizations, :admin_members, :members],
actor: current_user
)

Plug.Conn.assign(conn, :current_user, loaded_user)
end
elixir
def call(%{assigns: %{current_user: %{} = current_user}} = conn, _ops) do
loaded_user =
Ash.load!(
current_user,
[:display_name, :full_name, :organizations, :admin_members, :members],
actor: current_user
)

Plug.Conn.assign(conn, :current_user, loaded_user)
end
I have recently did a library update to {:phoenix, "~> 1.8.1"}, and {:phoenix_live_view, "~> 1.1.0"}, But the strange thing is that in :organizations, I have the last organisation repeated 21 extra times. Does someone knows why ? Regards, Angy
9 Replies
ZachDaniel
ZachDaniel2w ago
🤔 are you on the latest version of ash_postgres and ash_sql?
AngyL75
AngyL75OP2w ago
Hi @zach, I am using {:ash_postgres, "~> 2.5"}, and {:ecto_sql, "~> 3.10"}, and {:ash, "~> 3.0"},
ZachDaniel
ZachDaniel2w ago
What's in your lock file? Those are just version specs not the actual versions you are in Run mix deps.update ash ash_postgres ash_sql to ensure you're on latest And then run mix hex.outdated to see
AngyL75
AngyL75OP2w ago
"ash_postgres": {:hex, :ash_postgres, "2.6.19", "a74174233b4a953564bfd591aaf31ee153fb1cc6400409cf3d9da41dee3231f9", [:mix], [{:ash, ">= 3.5.35 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_sql, ">= 0.2.90 and < 1.0.0-0", [hex: :ash_sql, repo: "hexpm", optional: false]}, {:ecto, "~> 3.13", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.13", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.14 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "6c19e491abcd4c67c61d4fd41de71d0fea6ec720f78dce0f7d51af70ff017138"}, "ash_sql": {:hex, :ash_sql, "0.2.93", "d2e50a718f18e67bffa8fd9c7bea39d260ca746ca4df357bd9726a3ad4a39294", [:mix], [{:ash, ">= 3.5.35 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "492d811a636c19dad990c4f1af83761c0006ec5650970252f78cf4bd2b50b500"}, I hve updated it and I still have the same issue.
No description
ZachDaniel
ZachDaniel2w ago
Can you see if it happens if you remove the sort?
AngyL75
AngyL75OP2w ago
Yes, without the sorting it works ! I do not have duplication of the last one anymore. Is there some regression here ? in the past it used to work well, with the sort too.
ZachDaniel
ZachDaniel2w ago
I believe so yes Please open an issue. If possible, PR a failing test. Otherwise just an issue is fine.
AngyL75
AngyL75OP2w ago
Issue opened in Github with a link to this discusssion. If my description of the ticket is not sufficient, please let me know. Thanks 🙂
ZachDaniel
ZachDaniel2w ago
🙇‍♂️

Did you find this page helpful?