aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-29 11:43:58 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-29 11:43:58 -0700
commit6330a18636c7c07a5d01f294e2fa48413ddcb042 (patch)
tree12c94d43ab6e0ee9d0577ceaa7b6e14b69e3704b
parent27b09e04982abf37c98e6f7b64995c17e59ea7bb (diff)
parent1f5ed8eb20231644525bdad9a94a91e810191186 (diff)
downloadrails-6330a18636c7c07a5d01f294e2fa48413ddcb042.tar.gz
rails-6330a18636c7c07a5d01f294e2fa48413ddcb042.tar.bz2
rails-6330a18636c7c07a5d01f294e2fa48413ddcb042.zip
Merged pull request #48 from ernie/down_with_to_s.
Stop calling to_s on aliases, require them to be strings already.
-rw-r--r--lib/arel/alias_predication.rb2
-rw-r--r--lib/arel/nodes/function.rb4
-rw-r--r--test/visitors/test_depth_first.rb6
-rw-r--r--test/visitors/test_dot.rb2
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/arel/alias_predication.rb b/lib/arel/alias_predication.rb
index 3f3db7671e..f42e9ee1a6 100644
--- a/lib/arel/alias_predication.rb
+++ b/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 \ No newline at end of file
diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb
index 3263ff9cd4..85347fc028 100644
--- a/lib/arel/nodes/function.rb
+++ b/lib/arel/nodes/function.rb
@@ -6,12 +6,12 @@ module Arel
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
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index e078d4add5..5bbdf57697 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -50,14 +50,14 @@ module Arel
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 @@ module Arel
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
diff --git a/test/visitors/test_dot.rb b/test/visitors/test_dot.rb
index 2909d87799..b311246436 100644
--- a/test/visitors/test_dot.rb
+++ b/test/visitors/test_dot.rb
@@ -16,7 +16,7 @@ module Arel
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