From 8c73dad0761980061ce45018172034cad34cd585 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sat, 13 Sep 2014 19:35:34 -0700 Subject: `Extract#as` should not mutate the receiver Fixes https://github.com/rails/rails/issues/16913 --- lib/arel/nodes/extract.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lib/arel/nodes') diff --git a/lib/arel/nodes/extract.rb b/lib/arel/nodes/extract.rb index 64f5c3ff0f..7c69deadef 100644 --- a/lib/arel/nodes/extract.rb +++ b/lib/arel/nodes/extract.rb @@ -1,20 +1,14 @@ module Arel module Nodes class Extract < Arel::Nodes::Unary + include Arel::AliasPredication include Arel::Predications attr_accessor :field - attr_accessor :alias - def initialize expr, field, aliaz = nil + def initialize expr, field super(expr) @field = field - @alias = aliaz && SqlLiteral.new(aliaz) - end - - def as aliaz - self.alias = SqlLiteral.new(aliaz) - self end def hash @@ -23,8 +17,7 @@ module Arel def eql? other super && - self.field == other.field && - self.alias == other.alias + self.field == other.field end alias :== :eql? end -- cgit v1.2.3