On Aug 31, 11:00 pm, daniel_spaniel <[email protected]> wrote: > I tried your suggestions ( added graph_only_conditions, no dice .. > here is result sequel for the > Horse.eager_graph(:dude).first ( same result as with > Horses.eager_graph(:dude).limit(1).all.first )
Horse.eager_graph(:dude).first won't do what you want. It'll return a graph of results instead of an array of horses that already have the dude association set. You need to call .all if you are going to be doing any eager loading. > > SELECT `HORSES`.`NAME`, `HORSES`.`KID - DATE`, `HORSES`.`KID - TIME`, > `HORSES`.`KID - USER`, `HORSES`.`KID - MULT`, `HORSES`.`KID - COMM`, > `HORSES`.`DUDE KID - DATE`, `HORSES`.`DUDE KID - TIME`, `HORSES`.`DUDE > KID - USER`, `HORSES`.`DUDE KID - MULT`, `HORSES`.`DUDE KID - COMM`, > `DUDE`.`KID - DATE` AS `DUDE_KID - DATE`, `DUDE`.`KID - TIME` AS > `DUDE_KID - TIME`, `DUDE`.`KID - USER` AS `DUDE_KID - USER`, > `DUDE`.`KID - MULT` AS `DUDE_KID - MULT`, `DUDE`.`KID - COMM` AS > `DUDE_KID - COMM`, `DUDE`.`NAME` AS `DUDE_NAME`, `DUDE`.`RANCH CODE` > FROM `HORSES` LEFT OUTER JOIN `DUDES` AS `DUDE` ON ((`KID - DATE`, > `KID - TIME`, `KID - USER`, `KID - MULT`, `KID - COMM`) IS NULL) LIMIT > 1 > > the join sql is messed up after the LEFT OUTER JOIN ... ON part. > I did read that part on the advanced associations you were talking > about, and it was confusing. I will try again though. If you can pastie a self-executing example, I'll look into this more tomorrow. > Yes, you are right, for getting one record, its no big deal ( I am > just trying to give super simple example so I can learn ) , but in > reality I will be getting many records, and a few joins to various > other tables at the same time, and it will make huge difference then. OK. Just making sure. Some people think that queries are so expensive that you never want 2 when 1 will do. You are correct that it can make a huge difference for large datasets. Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
