aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-05 13:00:50 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-05 13:00:50 -0700
commit680e080bb4399312f63a699d2f103632b41be927 (patch)
treee2f6bc304622aa6913479ef74f797c62cc43f4b1 /lib
parentb9e90e4e55290172d7c5918319fd5fe35aa6a10e (diff)
downloadrails-680e080bb4399312f63a699d2f103632b41be927.tar.gz
rails-680e080bb4399312f63a699d2f103632b41be927.tar.bz2
rails-680e080bb4399312f63a699d2f103632b41be927.zip
string passthrough for "group by"
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/relations/relation.rb2
-rw-r--r--lib/arel/sql/formatters.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index 8c56a0cdcc..cd58f0f15c 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -11,7 +11,7 @@ module Arel
(joins(self) unless joins(self).blank? ),
("WHERE #{selects.collect { |s| s.to_sql(Sql::WhereClause.new(self)) }.join("\n\tAND ")}" unless selects.blank? ),
("ORDER BY #{orders.collect { |o| o.to_sql(Sql::OrderClause.new(self)) }.join(', ')}" unless orders.blank? ),
- ("GROUP BY #{groupings.collect(&:to_sql)}" unless groupings.blank? ),
+ ("GROUP BY #{groupings.collect { |g| g.to_sql(Sql::GroupClause.new(self)) }.join(', ')}" unless groupings.blank? ),
("LIMIT #{taken}" unless taken.blank? ),
("OFFSET #{skipped}" unless skipped.blank? )
].compact.join("\n"), name
diff --git a/lib/arel/sql/formatters.rb b/lib/arel/sql/formatters.rb
index 96bab2495c..5eab65726e 100644
--- a/lib/arel/sql/formatters.rb
+++ b/lib/arel/sql/formatters.rb
@@ -44,6 +44,12 @@ module Arel
end
end
+ class GroupClause < PassThrough
+ def attribute(attribute)
+ "#{quote_table_name(name_for(attribute.original_relation))}.#{quote_column_name(attribute.name)}"
+ end
+ end
+
class WhereCondition < Formatter
def attribute(attribute)
"#{quote_table_name(name_for(attribute.original_relation))}.#{quote_column_name(attribute.name)}"