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

WTF, tabs?

This commit is contained in:
Paul Sadauskas 2011-01-21 17:54:58 -07:00
parent 430d88b376
commit f0fe5e30da
4 changed files with 69 additions and 69 deletions

View file

@ -1,10 +1,10 @@
module Arel
module Nodes
class With < Arel::Nodes::Unary
alias children expr
end
module Nodes
class With < Arel::Nodes::Unary
alias children expr
end
class WithRecursive < With; end
end
class WithRecursive < With; end
end
end

View file

@ -31,7 +31,7 @@ module Arel
def where_clauses
if $VERBOSE
warn "(#{caller.first}) where_clauses is deprecated and will be removed in arel 3.0.0 with no replacement"
warn "(#{caller.first}) where_clauses is deprecated and will be removed in arel 3.0.0 with no replacement"
end
to_sql = Visitors::ToSql.new @engine
@ctx.wheres.map { |c| to_sql.accept c }
@ -135,24 +135,24 @@ module Arel
end
def union operation, other = nil
if operation.is_a? Symbol
node_class = Nodes.const_get("Union#{operation.to_s.capitalize}")
else
other = operation
node_class = Nodes::Union
end
if operation.is_a? Symbol
node_class = Nodes.const_get("Union#{operation.to_s.capitalize}")
else
other = operation
node_class = Nodes::Union
end
node_class.new self.ast, other.ast
end
node_class.new self.ast, other.ast
end
def with *subqueries
if subqueries.first.is_a? Symbol
node_class = Nodes.const_get("With#{subqueries.shift.to_s.capitalize}")
else
node_class = Nodes::With
end
@ast.with = node_class.new(subqueries.flatten)
end
if subqueries.first.is_a? Symbol
node_class = Nodes.const_get("With#{subqueries.shift.to_s.capitalize}")
else
node_class = Nodes::With
end
@ast.with = node_class.new(subqueries.flatten)
end
def take limit
@ast.limit = Nodes::Limit.new(limit)

View file

@ -48,7 +48,7 @@ module Arel
(#{caller.first}) Using UpdateManager without setting UpdateManager#key is
deprecated and support will be removed in ARel 3.0.0. Please set the primary
key on UpdateManager using UpdateManager#key=
eowarn
eowarn
key = o.relation.primary_key
end
@ -75,8 +75,8 @@ eowarn
"INSERT INTO #{visit o.relation}",
("(#{o.columns.map { |x|
quote_column_name x.name
}.join ', '})" unless o.columns.empty?),
quote_column_name x.name
}.join ', '})" unless o.columns.empty?),
(visit o.values if o.values),
].compact.join ' '
@ -129,7 +129,7 @@ eowarn
def visit_Arel_Nodes_SelectStatement o
[
(visit(o.with) if o.with),
(visit(o.with) if o.with),
o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join,
("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
(visit(o.limit) if o.limit),
@ -151,20 +151,20 @@ eowarn
end
def visit_Arel_Nodes_With o
"WITH #{o.children.map { |x| visit x }.join(', ')}"
end
"WITH #{o.children.map { |x| visit x }.join(', ')}"
end
def visit_Arel_Nodes_WithRecursive o
"WITH RECURSIVE #{o.children.map { |x| visit x }.join(', ')}"
end
def visit_Arel_Nodes_WithRecursive o
"WITH RECURSIVE #{o.children.map { |x| visit x }.join(', ')}"
end
def visit_Arel_Nodes_Union o
"( #{visit o.left} UNION #{visit o.right} )"
end
def visit_Arel_Nodes_Union o
"( #{visit o.left} UNION #{visit o.right} )"
end
def visit_Arel_Nodes_UnionAll o
"( #{visit o.left} UNION ALL #{visit o.right} )"
end
def visit_Arel_Nodes_UnionAll o
"( #{visit o.left} UNION ALL #{visit o.right} )"
end
def visit_Arel_Nodes_Having o
"HAVING #{visit o.expr}"
@ -303,11 +303,11 @@ eowarn
end
def visit_Arel_Nodes_In o
"#{visit o.left} IN (#{visit o.right})"
"#{visit o.left} IN (#{visit o.right})"
end
def visit_Arel_Nodes_NotIn o
"#{visit o.left} NOT IN (#{visit o.right})"
"#{visit o.left} NOT IN (#{visit o.right})"
end
def visit_Arel_Nodes_And o

View file

@ -48,9 +48,9 @@ module Arel
describe 'select manager' do
def test_join_sources
manager = Arel::SelectManager.new Table.engine
manager.join_sources << Arel::Nodes::StringJoin.new('foo')
assert_equal "SELECT FROM 'foo'", manager.to_sql
manager = Arel::SelectManager.new Table.engine
manager.join_sources << Arel::Nodes::StringJoin.new('foo')
assert_equal "SELECT FROM 'foo'", manager.to_sql
end
describe 'backwards compatibility' do
@ -179,41 +179,41 @@ module Arel
end
describe 'union' do
before do
table = Table.new :users
@m1 = Arel::SelectManager.new Table.engine, table
@m1.project Arel.star
@m1.where(table[:age].lt(18))
before do
table = Table.new :users
@m1 = Arel::SelectManager.new Table.engine, table
@m1.project Arel.star
@m1.where(table[:age].lt(18))
@m2 = Arel::SelectManager.new Table.engine, table
@m2.project Arel.star
@m2.where(table[:age].gt(99))
@m2 = Arel::SelectManager.new Table.engine, table
@m2.project Arel.star
@m2.where(table[:age].gt(99))
end
end
it 'should union two managers' do
# FIXME should this union "managers" or "statements" ?
# FIXME this probably shouldn't return a node
node = @m1.union @m2
it 'should union two managers' do
# FIXME should this union "managers" or "statements" ?
# FIXME this probably shouldn't return a node
node = @m1.union @m2
# maybe FIXME: decide when wrapper parens are needed
node.to_sql.must_be_like %{
( SELECT * FROM "users" WHERE "users"."age" < 18 UNION SELECT * FROM "users" WHERE "users"."age" > 99 )
}
end
# maybe FIXME: decide when wrapper parens are needed
node.to_sql.must_be_like %{
( SELECT * FROM "users" WHERE "users"."age" < 18 UNION SELECT * FROM "users" WHERE "users"."age" > 99 )
}
end
it 'should union all' do
node = @m1.union :all, @m2
it 'should union all' do
node = @m1.union :all, @m2
node.to_sql.must_be_like %{
( SELECT * FROM "users" WHERE "users"."age" < 18 UNION ALL SELECT * FROM "users" WHERE "users"."age" > 99 )
}
end
node.to_sql.must_be_like %{
( SELECT * FROM "users" WHERE "users"."age" < 18 UNION ALL SELECT * FROM "users" WHERE "users"."age" > 99 )
}
end
end
end
describe 'with' do
describe 'with' do
it "should support WITH RECURSIVE" do
comments = Table.new(:comments)
@ -249,7 +249,7 @@ module Arel
}
end
end
end
describe 'ast' do
it 'should return the ast' do