a = DB[:attributes] # [:node_id, :kind, :value] n = DB[:nodes] # [:id, :path] this = n.filter {:id => 1} j = this.left_outer_join(a) {n/:id == a/:node_id} j.select(:nodes.all, :) j.auto_alias(n.columns + a.columns) #=> {:t1_c1 => :nodes__id, :t1_c2 => :nodes__path, :t2_c1 => :attributes__node_id} j.sql #=> "SELECT nodes.id AS t1c1, nodes.path AS t1c2, attributes.node_id AS t2c1 FROM ..." j.columns #=> [:nodes__id, :nodes__path, :attributes__node_id, ... ] j.column_mapping #=> {:t1_c1 => :nodes__id, :t1_c2 => :nodes__path, :t2_c1 => :attributes__node_id} n = DB[:nodes] n.set_eager_join(:attributes) n.sql #=> "SELECT nodes.id AS t1c1, nodes.path AS t1c2, attributes.node_id AS t2c1 FROM ..." j.alias(n.columns + a.columns) n.eager_join(:attributes, )