Browse files

Merged pull request #48 from ernie/down_with_to_s.

Stop calling to_s on aliases, require them to be strings already.
  • Loading branch information...
2 parents 27b09e0 + 1f5ed8e commit 6330a18636c7c07a5d01f294e2fa48413ddcb042 @tenderlove tenderlove committed Apr 29, 2011
Showing with 7 additions and 7 deletions.
  1. +1 −1 lib/arel/alias_predication.rb
  2. +2 −2 lib/arel/nodes/function.rb
  3. +3 −3 test/visitors/test_depth_first.rb
  4. +1 −1 test/visitors/test_dot.rb
View
2 lib/arel/alias_predication.rb
@@ -1,7 +1,7 @@
module Arel
module AliasPredication
def as other
- Nodes::As.new self, Nodes::SqlLiteral.new(other.to_s)
+ Nodes::As.new self, Nodes::SqlLiteral.new(other)
end
end
end
View
4 lib/arel/nodes/function.rb
@@ -6,12 +6,12 @@ class Function < Arel::Nodes::Node
def initialize expr, aliaz = nil
@expressions = expr
- @alias = aliaz && SqlLiteral.new(aliaz.to_s)
+ @alias = aliaz && SqlLiteral.new(aliaz)
@distinct = false
end
def as aliaz
- self.alias = SqlLiteral.new(aliaz.to_s)
+ self.alias = SqlLiteral.new(aliaz)
self
end
end
View
6 test/visitors/test_depth_first.rb
@@ -50,14 +50,14 @@ def test_raises_with_object
Arel::Nodes::Sum,
].each do |klass|
define_method("test_#{klass.name.gsub('::', '_')}") do
- func = klass.new(:a, :b)
+ func = klass.new(:a, "b")
@visitor.accept func
assert_equal [:a, "b", false, func], @collector.calls
end
end
def test_named_function
- func = Arel::Nodes::NamedFunction.new(:a, :b, :c)
+ func = Arel::Nodes::NamedFunction.new(:a, :b, "c")
@visitor.accept func
assert_equal [:a, :b, false, "c", func], @collector.calls
end
@@ -69,7 +69,7 @@ def test_lock
end
def test_count
- count = Nodes::Count.new :a, :b, :c
+ count = Nodes::Count.new :a, :b, "c"
@visitor.accept count
assert_equal [:a, "c", :b, count], @collector.calls
end
View
2 test/visitors/test_dot.rb
@@ -16,7 +16,7 @@ def setup
Nodes::Avg,
].each do |klass|
define_method("test_#{klass.name.gsub('::', '_')}") do
- op = klass.new(:a, :z)
+ op = klass.new(:a, "z")
@visitor.accept op
end
end

0 comments on commit 6330a18

Please sign in to comment.