aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes/count.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-07 16:37:11 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-07 16:37:11 -0700
commit5ab502a755d0031d229278b6f14123c45623dd04 (patch)
tree3c2948cda53c1c33d69b8d81542ce2d407adc512 /lib/arel/nodes/count.rb
parentcea486ac810a92ef4f96ef84e3a412fd7a4f6925 (diff)
downloadrails-5ab502a755d0031d229278b6f14123c45623dd04.tar.gz
rails-5ab502a755d0031d229278b6f14123c45623dd04.tar.bz2
rails-5ab502a755d0031d229278b6f14123c45623dd04.zip
adding "as" and to_sql to count nodes
Diffstat (limited to 'lib/arel/nodes/count.rb')
-rw-r--r--lib/arel/nodes/count.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/arel/nodes/count.rb b/lib/arel/nodes/count.rb
index b7c4b60948..1222a791bb 100644
--- a/lib/arel/nodes/count.rb
+++ b/lib/arel/nodes/count.rb
@@ -1,11 +1,22 @@
module Arel
module Nodes
class Count
- attr_accessor :expressions, :distinct
+ attr_accessor :expressions, :distinct, :alias
def initialize expr, distinct = false
@expressions = expr
@distinct = distinct
+ @alias = nil
+ end
+
+ def as aliaz
+ self.alias = SqlLiteral.new(aliaz)
+ self
+ end
+
+ def to_sql
+ viz = Visitors::ToSql.new Table.engine
+ viz.accept self
end
end
end