On Jul 6, 7:56 pm, Phrogz <[email protected]> wrote:
> irb(main):001:0> require 'sequel'; DB = Sequel::sqlite;
> DB.quote_identifiers = false
> => false
>
> irb(main):002:0> ids = DB[ "SELECT 1 AS o_id, 2 AS m_id" ].as( :ids )
> => #<Sequel::SQL::AliasedExpression:0x401fa0
> @expression=#<Sequel::SQLite::Dataset: "SELECT 1 AS o_id, 2 AS m_id">,
> @aliaz=:ids>
>
> irb(main):003:0> DB.dataset.from( ids ).left_outer_join( DB
> [:objects].as(:objects), :id=>:o_id ).left_outer_join( DB[:methods].as
> (:methods), :id=>:m_id ).sql
> => "SELECT * FROM (SELECT 1 AS o_id, 2 AS m_id) AS 'ids' LEFT OUTER
> JOIN (SELECT * FROM objects) AS 'objects' ON (objects.id = ids.o_id)
> LEFT OUTER JOIN (SELECT * FROM methods) AS 'methods' ON (methods.id =
> objects.m_id)"
>
> Note at the end "objects.m_id" instead of "ids.m_id".
>
> Is the best way to fix this just to be explicit for every join after
> the first, e.g. :id=>:ids__m_id?

Yes, that's the recommended and easiest way.  You could also use
the :implicit_qualifier option (looks like the documentation has a
typo, it's :implicit_qualifier, not :implicit_qualifer), but that is
more suited for situations where you aren't hard coding things (like
eager_graph).

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

Reply via email to