1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Patch Informix Visitor so that it includes joins

This commit is contained in:
Jordan 2012-02-29 15:14:47 -05:00
parent b757de114c
commit 7cb1044343
2 changed files with 11 additions and 1 deletions

View file

@ -15,7 +15,7 @@ module Arel
def visit_Arel_Nodes_SelectCore o def visit_Arel_Nodes_SelectCore o
[ [
"#{o.projections.map { |x| visit x }.join ', '}", "#{o.projections.map { |x| visit x }.join ', '}",
("FROM #{visit o.froms}" if o.froms), ("FROM #{visit(o.source)}" if o.source && !o.source.empty?),
("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.empty?), ("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.empty?),
("GROUP BY #{o.groups.map { |x| visit x }.join ', ' }" unless o.groups.empty?), ("GROUP BY #{o.groups.map { |x| visit x }.join ', ' }" unless o.groups.empty?),
(visit(o.having) if o.having), (visit(o.having) if o.having),

View file

@ -37,6 +37,16 @@ module Arel
sql.must_be_like "SELECT SKIP 1 LIMIT 1" sql.must_be_like "SELECT SKIP 1 LIMIT 1"
end end
it 'uses INNER JOIN to perform joins' do
core = Nodes::SelectCore.new
table = Table.new(:posts)
core.source = Nodes::JoinSource.new(table, [table.create_join(Table.new(:comments))])
stmt = Nodes::SelectStatement.new([core])
sql = @visitor.accept(stmt)
sql.must_be_like 'SELECT FROM "posts" INNER JOIN "comments"'
end
end end
end end
end end