Join_relationship returning a single resource instead of a list

After updating to ash 2.19.1, my many_to_many relationship started returning one resource struct instead of a list.

In my resource, I have this relationship:

    many_to_many :schools, School do
      through UserSchool
      join_relationship :user_schools

      source_attribute_on_join_resource :user_id
      destination_attribute_on_join_resource :school_id

If i get the resource loading users_schools, I get the following:

   user_schools: #Core.Accounts.UserSchool<
     school: #Core.Accounts.School<
       users: #Ash.NotLoaded<:relationship, field: :users>,
       organization: #Ash.NotLoaded<:relationship, field: :organization>,
       school_users: #Ash.NotLoaded<:relationship, field: :school_users>,
       __meta__: #Ecto.Schema.Metadata<:loaded, "schools">,
       id: "02vClcLsoXciol3z5dqyOI",
       name: "Green Valley Elementary School",
       uid: "02vClWrwFT9V0pRxRALglK",
       creation_type: :predefined_school,
       geography: %Geo.Point{
         coordinates: {-86.8088, 33.3957},
         srid: 4326,
         properties: %{}
       address: "3200 Old Columbiana Rd - Hoover, 35226",
       city: "Hoover",
       district: "Hoover City",
       state: "AL",
       full_state: "Alabama (AL)",
       country: "USA",
       full_country: "United States",
       education_system: :k12,
       type: :public,
       b2b?: false,
       metadata: %{},
       inserted_at: ~U[2023-12-19 15:47:43.055266Z],
       updated_at: ~U[2023-12-19 15:47:43.055266Z],
       organization_id: "02vClcLsoZ5RMLWKjnTdCS",
       aggregates: %{},
       calculations: %{},
     user: #Ash.NotLoaded<:relationship, field: :user>,
     __meta__: #Ecto.Schema.Metadata<:loaded, "users_schools">,
     admin?: true,
     signature: nil,
     description: nil,
     metadata: %{},
     user_id: "02vCkiDruAshQWM9IIWget",
     school_id: "02vClcLsoXciol3z5dqyOI",
     aggregates: %{},
     calculations: %{},

Before 2.19, I would get a list of all the user schools in that attribute.

Yikes! Are you doing anything special when loading it?

I’ve just released a fix :slight_smile:

1 Like