diff options
Diffstat (limited to 'lib/arel/engines/sql/relations/relation.rb')
-rw-r--r-- | lib/arel/engines/sql/relations/relation.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/arel/engines/sql/relations/relation.rb b/lib/arel/engines/sql/relations/relation.rb index 12b328151f..940f985358 100644 --- a/lib/arel/engines/sql/relations/relation.rb +++ b/lib/arel/engines/sql/relations/relation.rb @@ -17,6 +17,7 @@ module Arel (joins(self) unless joins(self).blank? ), ("WHERE #{where_clauses.join("\n\tAND ")}" unless wheres.blank? ), ("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ), + ("HAVING #{having_clauses.join(', ')}" unless havings.blank? ), ("#{locked}" unless locked.blank? ) build_query \ @@ -32,6 +33,7 @@ module Arel (joins(self) unless joins(self).blank? ), ("WHERE #{where_clauses.join("\n\tAND ")}" unless wheres.blank? ), ("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ), + ("HAVING #{having_clauses.join(', ')}" unless havings.blank? ), ("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ), ("LIMIT #{taken}" unless taken.blank? ), ("OFFSET #{skipped}" unless skipped.blank? ), @@ -69,6 +71,10 @@ module Arel groupings.collect { |g| g.to_sql(Sql::GroupClause.new(self)) } end + def having_clauses + havings.collect { |g| g.to_sql(Sql::HavingClause.new(self)) } + end + def order_clauses orders.collect { |o| o.to_sql(Sql::OrderClause.new(self)) } end |