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 | |
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')
-rw-r--r-- | lib/arel/relations/relation.rb | 6 | ||||
-rw-r--r-- | lib/arel/relations/utilities/compound.rb | 4 |
2 files changed, 7 insertions, 3 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") diff --git a/lib/arel/relations/utilities/compound.rb b/lib/arel/relations/utilities/compound.rb index a91cec1127..b1e8054d4d 100644 --- a/lib/arel/relations/utilities/compound.rb +++ b/lib/arel/relations/utilities/compound.rb @@ -5,7 +5,7 @@ module Arel delegate :joins, :join?, :inserts, :taken, :skipped, :name, :externalizable?, :column_for, :engine, :table, :table_sql, :to => :relation - + [:attributes, :wheres, :groupings, :orders].each do |operation_name| operation = <<-OPERATION def #{operation_name} @@ -15,4 +15,4 @@ module Arel class_eval operation, __FILE__, __LINE__ end end -end
\ No newline at end of file +end |