On Wednesday, August 21, 2013 5:05:13 PM UTC-7, Fred Wu wrote:

> Hi Jeremy,
>
> Thanks for your response! Yeah I figured it'd be the case, I've written a 
> blog 
> post<http://fredwu.me/post/58910814911/gotchas-in-the-ruby-sequel-gem>shortly 
> after I posted my questions. If my assumption is correct - join and 
> eager generate different SQL queries right?
>

Correct.  join, eager, and eager_graph all operate very differently, and 
they all use different SQL (in some cases, multiple queries).  You can call 
#sql on any dataset to get the SQL it will use.  Also, you can add a logger 
to a Database to see all queries that are sent.

After reading your blog post, first I'd like to say I'm sorry that you are 
frustrated.  I appreciate you trying to add Sequel support to your library, 
and sorry that it didn't work in the way you expected.  That being said, 
there are good reasons for the way Sequel works currently.

In regards to your gotchas:

"Gotcha 1: Always use “select”/”select_all”, or your data records will 
mysteriously have wrong IDs!" This is misleading.  A more accurate title 
would be "If you manually join your model dataset to another table, you 
should explicitly specify what to select".  In general with models, you 
don't need to explicitly specify your columns if you are not joining, 
though for performance you should explicitly specify only the columns you 
plan to use.
"Gotcha 2: Always call “all" at the end of the chain, or the chain will 
present data in a different format."  Also misleading.  A more accurate 
title would be "When eagerly loading, you should always call all to get 
results".  Your post implies that there is no problem when doing 
eager(...).first, when the truth is no eager loading is done at all in that 
case.  For the regular join case, since you are not eagerly loading, you 
don't need to call all, as iterating over the results works fine.

If you can point me to specific places in the Sequel for ActiveRecord Users 
guide where you think I should address these issues, I will be happy to 
make such changes, so that future users can hopefully avoid them.

Thanks,
Jeremy

-- 
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