Decompose Composable Query

I have a composed query that preloads an association. I want to perform a subquery (to get a count on records), which restricts preloads. Since queries are structs, can the preload be removed before performing the subquery?

#Ecto.Query<from q0 in My.System.Quote, join: c1 in assoc(q0, :comment),
order_by: [desc: q0.inserted_at], preload: [comment: c1]>

Data type
This is a struct. Structs are maps with a struct key.
Reference modules
Ecto.Query, Map

You are looking for Ecto.Query.exclude/2 if I understand you correctly.


That is EXACTLY what I’m looking for! Thank you!

1 Like