aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/extensions/class.rb8
-rw-r--r--lib/arel/extensions/object.rb2
-rw-r--r--lib/arel/primitives/attribute.rb2
-rw-r--r--lib/arel/primitives/value.rb3
-rw-r--r--lib/arel/relations/join.rb4
-rw-r--r--lib/arel/relations/relation.rb13
6 files changed, 17 insertions, 15 deletions
diff --git a/lib/arel/extensions/class.rb b/lib/arel/extensions/class.rb
index 0e5b728c26..fed2ef79c7 100644
--- a/lib/arel/extensions/class.rb
+++ b/lib/arel/extensions/class.rb
@@ -1,12 +1,4 @@
class Class
- def abstract(*methods)
- methods.each do |method|
- define_method method do
- raise NotImplementedError
- end
- end
- end
-
def hash_on(delegatee)
define_method :eql? do |other|
self == other
diff --git a/lib/arel/extensions/object.rb b/lib/arel/extensions/object.rb
index 779098f7ea..69ec6a5dce 100644
--- a/lib/arel/extensions/object.rb
+++ b/lib/arel/extensions/object.rb
@@ -10,7 +10,7 @@ class Object
def equality_predicate_sql
'='
end
-
+
def metaclass
class << self
self
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index 5895f7e9b9..30c03839e2 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -35,9 +35,9 @@ module Arel
def ==(other)
self.class == other.class and
- relation == other.relation and
name == other.name and
@alias == other.alias and
+ relation == other.relation and
ancestor == other.ancestor
end
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb
index 5142eb45ca..8ed3c4ce30 100644
--- a/lib/arel/primitives/value.rb
+++ b/lib/arel/primitives/value.rb
@@ -17,7 +17,8 @@ module Arel
end
def ==(other)
- value == other.value
+ self.class == other.class and
+ value == other.value
end
def bind(relation)
diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb
index 5356e57394..c1c3150629 100644
--- a/lib/arel/relations/join.rb
+++ b/lib/arel/relations/join.rb
@@ -44,10 +44,10 @@ module Arel
end
def relation_for(attribute)
- x = [externalize(relation1), externalize(relation2)].max do |r1, r2|
+ [externalize(relation1), externalize(relation2)].max do |r1, r2|
o1, o2 = r1.relation_for(attribute), r2.relation_for(attribute)
a1, a2 = o1 && o1[attribute], o2 && o2[attribute]
-
+
attribute / a1 <=> attribute / a2
end.relation_for(attribute)
end
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index cd58f0f15c..fc47a129a0 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -138,12 +138,21 @@ module Arel
def attribute_for_name(name)
attributes.detect { |a| a.alias_or_name.to_s == name.to_s }
end
-
+
+ # TESTME - added relation_for(x)[x] because of AR
def attribute_for_attribute(attribute)
attributes.select { |a| a =~ attribute }.max do |a1, a2|
- (attribute / a1) <=> (attribute / a2)
+ (attribute / relation_for(a1)[a1]) <=> (attribute / relation_for(a2)[a2])
+ end
+ end
+
+ def attribute_for_attribute_with_memoization(attribute)
+ @attribute_for_attribute ||= Hash.new do |h, a|
+ h[a] = attribute_for_attribute_without_memoization(a)
end
+ @attribute_for_attribute[attribute]
end
+ alias_method_chain :attribute_for_attribute, :memoization
end
include AttributeAccessable