Hey Jeremy,
I remember a while back, I asked about the use of graph and eager_graph
together, and you said it wasn't possible and (IIRC) to use join instead of
graph.
I noticed something I thought was strange today.
Whenever I have a dataset with a join and call eager_graph.all, it issues 2
queries. So,
Model.where(status: 'pending').eager_graph(:association).all
=> one query, as expected
Model.join(:accounts, id: :account_id).eager_graph(:association).all
=> SELECT * FROM "models" INNER JOIN "accounts" ON ("accounts"."id" =
"models"."account_id")
=> SELECT <fields> FROM (
SELECT * FROM "models" INNER JOIN "accounts" ON ("accounts"."id" =
"models"."account_id")
) AS "models"
LEFT OUTER JOIN "associations" AS \"associations\" ON <snip>
My use case is that I have a base dataset with joins, but I want to be able
to support dynamic `?include=association` from query params.
Implemented like this: base_dataset.eager_graph(*includes) if includes.any?
Any ideas on this use case and the extra query?
Thanks,
Matt
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/ec204813-4a1b-4be8-86a9-f306211b3c90n%40googlegroups.com.