diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-04-28 18:51:15 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-04-28 18:51:15 -0300 |
commit | 1dfae3a5a01b05bf14de88958b625b865748387b (patch) | |
tree | b8e1a63e893a46447bcd593d0f87d7303c9fe0b0 /lib/arel/relations/relation.rb | |
parent | 45646ec54c4c4a3c7340b79deea9e3cf76554f0b (diff) | |
download | rails-1dfae3a5a01b05bf14de88958b625b865748387b.tar.gz rails-1dfae3a5a01b05bf14de88958b625b865748387b.tar.bz2 rails-1dfae3a5a01b05bf14de88958b625b865748387b.zip |
ORDER BY should be included after GROUP BY clause
Diffstat (limited to 'lib/arel/relations/relation.rb')
-rw-r--r-- | lib/arel/relations/relation.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 50110c7416..986bc3fbeb 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -4,6 +4,10 @@ module Arel Session.new end + def select_value + engine.select_value self.to_sql + end + def select_values engine.select_values self.to_sql end @@ -19,8 +23,8 @@ module Arel "FROM #{table_sql(Sql::TableReference.new(self))}", (joins(self) unless joins(self).blank? ), ("WHERE #{wheres .collect { |w| w.to_sql(Sql::WhereClause.new(self)) }.join("\n\tAND ")}" unless wheres.blank? ), - ("ORDER BY #{orders .collect { |o| o.to_sql(Sql::OrderClause.new(self)) }.join(', ')}" unless orders.blank? ), ("GROUP BY #{groupings.collect { |g| g.to_sql(Sql::GroupClause.new(self)) }.join(', ')}" unless groupings.blank? ), + ("ORDER BY #{orders .collect { |o| o.to_sql(Sql::OrderClause.new(self)) }.join(', ')}" unless orders.blank? ), ("LIMIT #{taken}" unless taken.blank? ), ("OFFSET #{skipped}" unless skipped.blank? ) ].compact.join("\n") |