Hey all ,
I have discovered a preload behavior that I am not sure is intentional or not.
Setting
There is a Company (id: 8) with 2 associated CompanyProducts (company_id: 8).
When I query the company, join the company products and group by the company products I expect a result with 2 entries.
Question
When I explicitly tell an existing join (company_products) to be preloaded into the result set, it goes down to 1 entry. Is this intended? If yes, why?
query =
from(companies in Company,
join: company_products in assoc(companies, :company_products),
where: companies.id == 8,
group_by: [companies.id, company_products.id],
preload: [:company_products]
)
Repo.all(query) |> length()
--> 2
***********************************************************************
query =
from(companies in Company,
join: company_products in assoc(companies, :company_products),
where: companies.id == 8,
group_by: [companies.id, company_products.id],
preload: [company_products: company_products]
)
Repo.all(query) |> length()
--> 1
Thanks in advance, Dirk