Hello, I'll explain my question on example. Imagine we have two associated 
models

class Application < Sequel::Model
  one_to_many :screens
end

class Screen < Sequel:Model
  many_to_one :application
end

Nothing special here. So now to the question, examples again:

> Application[0].screens[0].application.name
(0.002000s) SELECT * FROM "applications" WHERE "id" = 1
(0.002000s) SELECT * FROM "screens" WHERE ("screens"."application_id" = 1)
=> "Foo"

Makes sense, there's no need to load application again to get its name. But:

> Application[0].screens_dataset.all[0].application.name

(0.001000s) SELECT * FROM "applications" WHERE "id" = 1
(0.002000s) SELECT * FROM "screens" WHERE ("screens"."application_id" = 1)
(0.001000s) SELECT * FROM "applications" WHERE "id" = 1
=> "Foo"

Thats the part I don't understand. Why is application loaded again? Its 
producing 1+n queries, sure I can use eager loading to load application for 
every screen, but it will again produce one more SQL call to load same 
application.

Is there something I am missing?

Thanks a lot

Petr

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to