aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r--lib/arel/nodes/extract.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/arel/nodes/extract.rb b/lib/arel/nodes/extract.rb
new file mode 100644
index 0000000000..1c9ee78816
--- /dev/null
+++ b/lib/arel/nodes/extract.rb
@@ -0,0 +1,23 @@
+module Arel
+ module Nodes
+
+ class Extract < Arel::Nodes::Unary
+ include Arel::Expression
+ include Arel::Predications
+
+ attr_accessor :field
+ attr_accessor :alias
+
+ def initialize expr, field, aliaz = nil
+ super(expr)
+ @field = field
+ @alias = aliaz && SqlLiteral.new(aliaz)
+ end
+
+ def as aliaz
+ self.alias = SqlLiteral.new(aliaz)
+ self
+ end
+ end
+ end
+end