On Friday, March 27, 2015 at 3:42:34 PM UTC-7, Janko Marohnić wrote:
>
> I'm not entirely sure what you meant. I would find it nice that, if I 
> don't qualify a column, that it gets automatically qualified to the 
> underlying model's table. This way I don't have to know if I'll be doing 
> joins while building a query (I would rather not have to qualify column 
> names if I don't have to). For example, I might do:
>
> Quiz.where(id: selected_quiz_ids).association_left_join(:questions).where
> {...}
>
> When that query finishes, I will get an "ambiguous column 'id'" error. 
> Even though I know that I meant "quizzes.id"; if I wanted `questions.id`, 
> I would be natural to explicitly specify it. I found out now that 
> "column_select" plugin actually does something else than this. Is there a 
> plugin which does this automatically?
>

I'm not aware of one, and I don't plan to add one.  Handling this 
generically (i.e. not just for hashes passed directly to #where, but for 
subexpressions) would basically require running an ASTTransformer on all 
inputs to #where and similar methods.  Handling this only for hashes passed 
directly to #where would result in inconsistent behavior.

Note that you can do:

  Quiz.where(id: selected_quiz_ids).qualify.association_left_join(...)

which will do what you want.

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/d/optout.

Reply via email to