From a0dc6900330b7ec78785a80fe8b72595384635a0 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 11 Apr 2008 18:32:47 -0700 Subject: fixed bug with take/skip --- lib/active_relation/relations/compound.rb | 4 ++-- lib/active_relation/relations/relation.rb | 8 ++++---- lib/active_relation/relations/skip.rb | 10 +++++----- lib/active_relation/relations/take.rb | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/active_relation/relations/compound.rb b/lib/active_relation/relations/compound.rb index c5af453e4b..aa3274cbd3 100644 --- a/lib/active_relation/relations/compound.rb +++ b/lib/active_relation/relations/compound.rb @@ -4,8 +4,8 @@ module ActiveRelation hash_on :relation - delegate :joins, :selects, :orders, :groupings, :table_sql, :inserts, :take, - :skip, :name, :alias, :aggregation?, :alias?, :prefix_for, :column_for, + delegate :joins, :selects, :orders, :groupings, :table_sql, :inserts, :taken, + :skipped, :name, :alias, :aggregation?, :alias?, :prefix_for, :column_for, :engine, :to => :relation diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index b26fac4e85..29c6fbbed0 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -120,8 +120,8 @@ module ActiveRelation ("WHERE #{selects.collect { |s| s.to_sql(Sql::WhereClause.new(engine)) }.join("\n\tAND ")}" unless selects.blank? ), ("ORDER BY #{orders.collect { |o| o.to_sql(Sql::OrderClause.new(engine)) }.join(', ')}" unless orders.blank? ), ("GROUP BY #{groupings.collect(&:to_sql)}" unless groupings.blank? ), - ("LIMIT #{take}" unless take.blank? ), - ("OFFSET #{skip}" unless skip.blank? ) + ("LIMIT #{taken}" unless taken.blank? ), + ("OFFSET #{skipped}" unless skipped.blank? ) ].compact.join("\n"), self.alias end alias_method :to_s, :to_sql @@ -159,8 +159,8 @@ module ActiveRelation def inserts; [] end def groupings; [] end def joins; nil end - def take; nil end - def skip; nil end + def taken; nil end + def skipped; nil end def alias; nil end end end \ No newline at end of file diff --git a/lib/active_relation/relations/skip.rb b/lib/active_relation/relations/skip.rb index f963ee6468..7fd5e1603a 100644 --- a/lib/active_relation/relations/skip.rb +++ b/lib/active_relation/relations/skip.rb @@ -1,18 +1,18 @@ module ActiveRelation class Skip < Compound - attr_reader :skip + attr_reader :skipped - def initialize(relation, skip) - @relation, @skip = relation, skip + def initialize(relation, skipped) + @relation, @skipped = relation, skipped end def ==(other) relation == other.relation and - skip == other.skip + skipped == other.skipped end def descend(&block) - Skip.new(relation.descend(&block), skip) + Skip.new(relation.descend(&block), skipped) end end end \ No newline at end of file diff --git a/lib/active_relation/relations/take.rb b/lib/active_relation/relations/take.rb index 9f98207798..efeff11bf2 100644 --- a/lib/active_relation/relations/take.rb +++ b/lib/active_relation/relations/take.rb @@ -1,18 +1,18 @@ module ActiveRelation class Take < Compound - attr_reader :take + attr_reader :taken - def initialize(relation, take) - @relation, @take = relation, take + def initialize(relation, taken) + @relation, @taken = relation, taken end def ==(other) relation == other.relation and - take == other.take + taken == other.taken end def descend(&block) - Take.new(relation.descend(&block), take) + Take.new(relation.descend(&block), taken) end end end \ No newline at end of file -- cgit v1.2.3