aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/nodes/extract.rb13
-rw-r--r--lib/arel/visitors/to_sql.rb9
2 files changed, 4 insertions, 18 deletions
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
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index ae1b7930af..ca09373b64 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -475,14 +475,7 @@ module Arel
def visit_Arel_Nodes_Extract o, collector
collector << "EXTRACT(#{o.field.to_s.upcase} FROM "
- collector = visit o.expr, collector
- collector << ")"
- if o.alias
- collector << " AS "
- visit o.alias, collector
- else
- collector
- end
+ visit(o.expr, collector) << ")"
end
def visit_Arel_Nodes_Count o, collector