On May 14, 6:41 pm, Paploo <[email protected]> wrote:
> Hopefully I am just missing how eager associations work in Sequel:
>
> I am trying to get eager loading working for a simple association
> whose foreign key is different than the default. I can see the
> correct sequel statement running in the log, but the cached value
> comes up empty.
>
> I assume I could work around it with a custom :eager_block, but for
> such a simple association, this seems silly.
>
> I have created a project which makes a simple test for the bug via
> some rspecs that fail for me (along with a copy/paste of the failures
> I got), and posted it at: http://github.com/paploo/sequel_eager_test/
>
> If you have any questions, you are welcome to message me at my github
> account, or directly at my posted e-mail address.
>
> Btw, thanks for the awesome ORM. We did a week long search and test
> of ORMs before we settled on this one. :)
The errors are due to the use of a string instead of a symbol for key
option. They should be fixed with:
class Alias < Sequel::Model
many_to_one :author, :key => :foo_id
end
class Author < Sequel::Model
one_to_many :articles
one_to_many :aliases, :key => :foo_id
end
The use of a symbol for the option is explicitly mentioned in the
documentation (http://sequel.rubyforge.org/rdoc/classes/Sequel/Model/
Associations/ClassMethods.html), though I suppose it isn't obvious if
you are coming from ActiveRecord. In general, Sequel uses ruby
symbols for SQL columns and ruby strings for SQL strings. That a
string works when lazy loading is purely an implementation detail,
it's not by design and it could change in the future. :)
I'm glad you chose Sequel for your ORM needs. Could you elaborate on
the reasons you chose Sequel (pros/cons compared to other ORMs)? I'm
always interested in other people's opinions about how Sequel compares
to other ORMs.
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
-~----------~----~----~----~------~----~------~--~---