On Sep 5, 11:51 am, Dmitry Sviridov <[email protected]> wrote: > I noticed that manual selection of attributes through :select doesn't > work while eager loading. > > From code: > class Artist < Sequel::Model > one_to_many :albums, :select => [:id, :name] > end > artists = Artist.eager(:albums).all > > From log: > SELECT * FROM `artists` > SELECT `id`, `name` FROM `albums` WHERE (`albums`.`artist_id` IN (1, > 2, 3, 4, 5)) > > Works as expected, but then artists[n].albums returns an empty list. > Though it works properly without :select. > > Looks like a bug?
I don't consider it a bug. You need to make sure to select the related key field in addition to the other fields (:artist_id in this case). I have thought about attempting to check if the key column(s) are already present, and add them if not, but I don't believe it is possible to do that correctly in all cases. 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.
