Hi everyone,

I have a question regarding the behaviour of joined records - I have to 
confess that I don't use Sequel often, so my understanding of the Sequel 
API is rather limited and I apologise. The back story is that I'm 
implementing a Sequel data provider as I develop the gem called 
Datamappify<https://github.com/fredwu/datamappify>
.

Recently I've run into a weird issue where certain records are missing. 
After a few frustrating days and nights, I've finally found where the 
problem was - it was the different behaviour (compared to ActiveRecord) 
that got me.

Long story short, in ActiveRecord, I could do:

Post.joins(:author)

Assuming a one-one relationship, that will get me all the posts with their 
corresponding authors.

So naturally, after consulting the Sequel for ActiveRecord users 
guide<http://sequel.rubyforge.org/rdoc/files/doc/active_record_rdoc.html>, 
I did this in Sequel:

Post.join(:authors, :id => :author_id)

This is fine until I realised that the ID in Post records are being 
replaced by the ID from the corresponding Author records! As a result I had 
to do the following:

Post.join(:authors, :id => :author_id).select(:posts__id, :posts__title, 
:posts__body)

Is this the correct usage? I tried to look into the source code but didn't 
find a way to automatically add prefixes to the hash keys.

On a side note, I also found the eager loading API slightly more difficult 
to use than ActiveRecord - mainly due to the requirement of calling `all` 
on the end of the chain, otherwise the results would end up being hashes. :/

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to