aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql/relations/operations
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-17 14:20:29 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 14:24:06 -0400
commitbdca9ed42ffea10aa6989ea3ecebedb424fa01ed (patch)
tree80682aa1c8fe544f1e91ccb8c529e66c8a1ddc94 /lib/arel/engines/sql/relations/operations
parent2bbf8ca9d2af3ea959a21c3729b4894bc31f088b (diff)
downloadrails-bdca9ed42ffea10aa6989ea3ecebedb424fa01ed.tar.gz
rails-bdca9ed42ffea10aa6989ea3ecebedb424fa01ed.tar.bz2
rails-bdca9ed42ffea10aa6989ea3ecebedb424fa01ed.zip
moved sql related code to its own engine area
Conflicts: lib/arel/engine.rb lib/arel/extensions/object.rb lib/arel/predicates.rb lib/arel/primitives/attribute.rb lib/arel/primitives/expression.rb lib/arel/primitives/value.rb lib/arel/relations/operations/join.rb lib/arel/relations/relation.rb lib/arel/relations/utilities/externalization.rb lib/arel/relations/utilities/nil.rb lib/arel/relations/writes/delete.rb lib/arel/relations/writes/insert.rb lib/arel/relations/writes/update.rb spec/arel/unit/relations/skip_spec.rb spec/arel/unit/relations/take_spec.rb spec/spec_helper.rb
Diffstat (limited to 'lib/arel/engines/sql/relations/operations')
-rw-r--r--lib/arel/engines/sql/relations/operations/alias.rb5
-rw-r--r--lib/arel/engines/sql/relations/operations/join.rb19
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/arel/engines/sql/relations/operations/alias.rb b/lib/arel/engines/sql/relations/operations/alias.rb
new file mode 100644
index 0000000000..32c9911a69
--- /dev/null
+++ b/lib/arel/engines/sql/relations/operations/alias.rb
@@ -0,0 +1,5 @@
+module Arel
+ class Alias < Compound
+ include Recursion::BaseCase
+ end
+end \ No newline at end of file
diff --git a/lib/arel/engines/sql/relations/operations/join.rb b/lib/arel/engines/sql/relations/operations/join.rb
new file mode 100644
index 0000000000..be21119bc9
--- /dev/null
+++ b/lib/arel/engines/sql/relations/operations/join.rb
@@ -0,0 +1,19 @@
+module Arel
+ class Join < Relation
+ def table_sql(formatter = Sql::TableReference.new(self))
+ relation1.externalize.table_sql(formatter)
+ end
+
+ def joins(environment, formatter = Sql::TableReference.new(environment))
+ @joins ||= begin
+ this_join = [
+ join_sql,
+ relation2.externalize.table_sql(formatter),
+ ("ON" unless predicates.blank?),
+ (ons + relation2.externalize.wheres).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
+ ].compact.join(" ")
+ [relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
+ end
+ end
+ end
+end \ No newline at end of file