aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-17 23:35:51 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-17 23:35:51 -0700
commit7a068384b74813b3ea9a309d237c6ce8e8fde5d6 (patch)
treeb0c39ba5e687c03cef1dfa93356eacb04ede5b8f
parent6e1450a2a646e416aaea003eff19b7703c563bed (diff)
downloadrails-7a068384b74813b3ea9a309d237c6ce8e8fde5d6.tar.gz
rails-7a068384b74813b3ea9a309d237c6ce8e8fde5d6.tar.bz2
rails-7a068384b74813b3ea9a309d237c6ce8e8fde5d6.zip
still faster
-rw-r--r--lib/arel/extensions/object.rb4
-rw-r--r--lib/arel/predicates.rb2
-rw-r--r--lib/arel/primitives/attribute.rb6
-rw-r--r--lib/arel/primitives/value.rb4
-rw-r--r--spec/arel/unit/predicates/binary_spec.rb2
5 files changed, 15 insertions, 3 deletions
diff --git a/lib/arel/extensions/object.rb b/lib/arel/extensions/object.rb
index 0382ca8027..9b66fcac4e 100644
--- a/lib/arel/extensions/object.rb
+++ b/lib/arel/extensions/object.rb
@@ -3,6 +3,10 @@ class Object
Arel::Value.new(self, relation)
end
+ def circle(relation)
+ bind(relation)
+ end
+
def to_sql(formatter)
formatter.scalar self
end
diff --git a/lib/arel/predicates.rb b/lib/arel/predicates.rb
index 3d01d5872f..48283e5d09 100644
--- a/lib/arel/predicates.rb
+++ b/lib/arel/predicates.rb
@@ -17,7 +17,7 @@ module Arel
end
def bind(relation)
- self.class.new(relation[operand1] || operand1, relation[operand2] || operand2)
+ self.class.new(operand1.circle(relation), operand2.circle(relation))
end
def to_sql(formatter = nil)
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index cb564c1587..eeea495b09 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -38,12 +38,16 @@ module Arel
end
def original_relation
- original_attribute.relation
+ @original_relation ||= original_attribute.relation
end
def original_attribute
@original_attribute ||= history.detect { |a| !a.join? }
end
+
+ def circle(relation)
+ relation[self]
+ end
module Transformations
def self.included(klass)
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb
index b4bddd0b0c..7751390be6 100644
--- a/lib/arel/primitives/value.rb
+++ b/lib/arel/primitives/value.rb
@@ -24,5 +24,9 @@ module Arel
def bind(relation)
Value.new(value, relation)
end
+
+ def circle(relation)
+ bind(relation)
+ end
end
end \ No newline at end of file
diff --git a/spec/arel/unit/predicates/binary_spec.rb b/spec/arel/unit/predicates/binary_spec.rb
index 2d6ef5d7e3..e5b30b787d 100644
--- a/spec/arel/unit/predicates/binary_spec.rb
+++ b/spec/arel/unit/predicates/binary_spec.rb
@@ -72,7 +72,7 @@ module Arel
describe 'when an operand is a value' do
it "manufactures an expression with unmodified values" do
ConcreteBinary.new(@attribute1, "asdf").bind(@another_relation). \
- should == ConcreteBinary.new(@another_relation[@attribute1], "asdf")
+ should == ConcreteBinary.new(@attribute1.circle(@another_relation), "asdf".circle(@another_relation))
end
end
end