Say I have some three tables in the database:

DB.create_table :people do
  primary_key :id
  String :name
  Integer :age
end

DB.create_table :employees do
  primary_key :id
  String :employee
  Integer :salary
end

DB.create_table :customers do
  primary_key :id
  String :costomer
end

p = DB[:people]
e = DB[:employees]
c = DB[:customers]


And I want to perform two joins across the three tables

j1 = p.join(:employees, employee: :name)
j2 = j1.join(:customers, customer: :name)

j2 will generate a faulty SQL query (calling j2.all, e.g., will show this). 
This is because it looks for the name column of the employees table rather 
than the people table. 

Is there any way to perform a join on costumers' costumer column and 
people's name column, given the query j1 as a starting point? What exactly 
are the semantics here? Is the default table who's column will be joined on 
taken from prior given arguments to join, e.g. from :employees being the 
first argument in the first call to join?

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

Reply via email to