aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql/relations/relation.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-02-18 19:17:55 -0300
committerEmilio Tagua <miloops@gmail.com>2010-02-18 19:17:55 -0300
commit18b2a3ce6b4519b7d5e0f4a63bc6cfb5b8808632 (patch)
treec83e7c71104776801ed63f283f7e32341ef913a7 /lib/arel/engines/sql/relations/relation.rb
parent39d88b8bce309fe9bdc1011b312c857ef194fbfa (diff)
downloadrails-18b2a3ce6b4519b7d5e0f4a63bc6cfb5b8808632.tar.gz
rails-18b2a3ce6b4519b7d5e0f4a63bc6cfb5b8808632.tar.bz2
rails-18b2a3ce6b4519b7d5e0f4a63bc6cfb5b8808632.zip
Insertions should use insert and not execute to get a valid returning
value. Moved clasuses to Arel::Relation.
Diffstat (limited to 'lib/arel/engines/sql/relations/relation.rb')
-rw-r--r--lib/arel/engines/sql/relations/relation.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/arel/engines/sql/relations/relation.rb b/lib/arel/engines/sql/relations/relation.rb
index 5038e1db81..52b91c71ea 100644
--- a/lib/arel/engines/sql/relations/relation.rb
+++ b/lib/arel/engines/sql/relations/relation.rb
@@ -25,8 +25,34 @@ module Arel
@primary_key ||= begin
table.name.classify.constantize.primary_key
rescue NameError
- "id"
+ nil
end
end
+
+ protected
+
+ def from_clauses
+ sources.blank? ? table_sql(Sql::TableReference.new(self)) : sources
+ end
+
+ def select_clauses
+ attributes.collect { |a| a.to_sql(Sql::SelectClause.new(self)) }
+ end
+
+ def where_clauses
+ wheres.collect { |w| w.to_sql(Sql::WhereClause.new(self)) }
+ end
+
+ def group_clauses
+ 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
end
end