aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:35:11 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:35:11 -0700
commit2d3681bb3c9ed8136fc46857828b74ae39b6d990 (patch)
tree3d1cb0091a093197499247ddffa8d7515e1ebec6 /lib
parent7bd0d634867ccbdf4537ba3d62b865b1cb7beebf (diff)
downloadrails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.tar.gz
rails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.tar.bz2
rails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.zip
nested orderings
Diffstat (limited to 'lib')
-rw-r--r--lib/active_relation/predicates.rb6
-rw-r--r--lib/active_relation/relations/join.rb5
-rw-r--r--lib/active_relation/relations/order.rb9
-rw-r--r--lib/active_relation/relations/selection.rb3
-rw-r--r--lib/active_relation/relations/table.rb1
5 files changed, 10 insertions, 14 deletions
diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb
index f68ec991c3..6fcef3cfd6 100644
--- a/lib/active_relation/predicates.rb
+++ b/lib/active_relation/predicates.rb
@@ -40,35 +40,30 @@ module ActiveRelation
(operand1 == other.operand2 and operand2 == other.operand1))
end
- protected
def predicate_sql
'='
end
end
class GreaterThanOrEqualTo < Binary
- protected
def predicate_sql
'>='
end
end
class GreaterThan < Binary
- protected
def predicate_sql
'>'
end
end
class LessThanOrEqualTo < Binary
- protected
def predicate_sql
'<='
end
end
class LessThan < Binary
- protected
def predicate_sql
'<'
end
@@ -79,7 +74,6 @@ module ActiveRelation
end
class In < Binary
- protected
delegate :predicate_sql, :to => :operand2
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/join.rb b/lib/active_relation/relations/join.rb
index 835e965f72..ab5f440d9e 100644
--- a/lib/active_relation/relations/join.rb
+++ b/lib/active_relation/relations/join.rb
@@ -36,7 +36,6 @@ module ActiveRelation
Join.new(join_sql, relation1.descend(&block), relation2.descend(&block), *predicates.collect(&block))
end
- protected
def joins
this_join = [
join_sql,
@@ -64,11 +63,11 @@ module ActiveRelation
delegate :engine, :to => :relation
def table_sql
- relation.aggregation?? relation.to_sql(Sql::TableReference.new(engine)) : relation.send(:table_sql)
+ relation.aggregation?? relation.to_sql(Sql::TableReference.new(engine)) : relation.table_sql
end
def selects
- relation.aggregation?? [] : relation.send(:selects)
+ relation.aggregation?? [] : relation.selects
end
def attributes
diff --git a/lib/active_relation/relations/order.rb b/lib/active_relation/relations/order.rb
index 6949b3acf7..bfd05f48b3 100644
--- a/lib/active_relation/relations/order.rb
+++ b/lib/active_relation/relations/order.rb
@@ -1,9 +1,10 @@
module ActiveRelation
class Order < Compound
- attr_reader :orders
+ attr_reader :order
def initialize(relation, *orders)
- @relation, @orders = relation, orders
+ @order = orders.pop
+ @relation = orders.empty?? relation : Order.new(relation, *orders)
end
def ==(other)
@@ -15,5 +16,9 @@ module ActiveRelation
def descend(&block)
Order.new(relation.descend(&block), *orders.collect(&block))
end
+
+ def orders
+ relation.orders + [order]
+ end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/selection.rb b/lib/active_relation/relations/selection.rb
index e7a91f7572..fe28908cc2 100644
--- a/lib/active_relation/relations/selection.rb
+++ b/lib/active_relation/relations/selection.rb
@@ -17,9 +17,8 @@ module ActiveRelation
Selection.new(relation.descend(&block), yield(predicate))
end
- protected
def selects
- relation.send(:selects) + [predicate]
+ relation.selects + [predicate]
end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/table.rb b/lib/active_relation/relations/table.rb
index 4682298608..72682bee55 100644
--- a/lib/active_relation/relations/table.rb
+++ b/lib/active_relation/relations/table.rb
@@ -44,7 +44,6 @@ module ActiveRelation
@attributes = @columns = nil
end
- protected
def table_sql
"#{engine.quote_table_name(name)}"
end