diff options
-rw-r--r-- | lib/arel/algebra/relations/operations/take.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/arel/algebra/relations/operations/take.rb b/lib/arel/algebra/relations/operations/take.rb index cc636642b1..964aacacca 100644 --- a/lib/arel/algebra/relations/operations/take.rb +++ b/lib/arel/algebra/relations/operations/take.rb @@ -1,8 +1,29 @@ module Arel class Take < Compound - attributes :relation, :taken - deriving :initialize, :== - requires :limiting + attr_reader :taken + + def initialize relation, taken + super(relation) + @taken = taken + end + + def == other + super || + Take === other && + relation == other.relation && + taken == other.taken + end + + def engine + engine = relation.engine + + # Temporary check of whether or not the engine supports where. + if engine.respond_to?(:supports) && !engine.supports(:limiting) + Memory::Engine.new + else + engine + end + end def externalizable? true |