diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 14:46:08 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 14:46:08 -0400 |
commit | 892337509b2bd269920dc567bc48c6a28c7222d2 (patch) | |
tree | 442843e51bce0a9bda8b1a83d30252a39d37e2d3 /lib/arel/engines | |
parent | b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3 (diff) | |
download | rails-892337509b2bd269920dc567bc48c6a28c7222d2.tar.gz rails-892337509b2bd269920dc567bc48c6a28c7222d2.tar.bz2 rails-892337509b2bd269920dc567bc48c6a28c7222d2.zip |
removed function_sql in favor of polymorphism
Conflicts:
lib/arel/algebra/primitives/attribute.rb
lib/arel/algebra/primitives/expression.rb
spec/arel/unit/primitives/expression_spec.rb
Diffstat (limited to 'lib/arel/engines')
-rw-r--r-- | lib/arel/engines/sql/primitives.rb | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/arel/engines/sql/primitives.rb b/lib/arel/engines/sql/primitives.rb index 5544d63710..c4968558a2 100644 --- a/lib/arel/engines/sql/primitives.rb +++ b/lib/arel/engines/sql/primitives.rb @@ -13,12 +13,6 @@ module Arel end end - class Expression < Attribute - def to_sql(formatter = Sql::SelectClause.new(relation)) - formatter.expression self - end - end - class Value def to_sql(formatter = Sql::WhereCondition.new(relation)) formatter.value value @@ -28,4 +22,34 @@ module Arel object.to_sql(Sql::Value.new(relation)) end end + + class Expression < Attribute + def to_sql(formatter = Sql::SelectClause.new(relation)) + formatter.expression self + end + end + + class Count < Expression + def function_sql; 'COUNT' end + end + + class Distinct < Expression + def function_sql; 'DISTINCT' end + end + + class Sum < Expression + def function_sql; 'SUM' end + end + + class Maximum < Expression + def function_sql; 'MAX' end + end + + class Minimum < Expression + def function_sql; 'MIN' end + end + + class Average < Expression + def function_sql; 'AVG' end + end end
\ No newline at end of file |