<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,9 +1,10 @@
 todo:
-- cross-engine joins
+- fix AR again
 - blocks for joins
 - fix sql insertions 
 - implement mnesia adapter
 
+- CLEANUP!!!!!
 - rename externalize to derived.
 - deal with table tests in algebra
 - fix grouping
@@ -94,6 +95,7 @@ done:
 - result sets should be array relations
 - fix AR
 - insertions for in memory
+- cross-engine joins
 
 icebox:
 - #bind in Attribute and Expression should be doing a descend?</diff>
      <filename>doc/TODO</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ module Arel
   class Join &lt; Relation
     attributes :relation1, :relation2, :predicates
     deriving :==
-    delegate :engine, :name, :to =&gt; :relation1
+    delegate :name, :to =&gt; :relation1
     hash_on :relation1
 
     def initialize(relation1, relation2 = Nil.instance, *predicates)
@@ -31,6 +31,10 @@ module Arel
     def join?
       true
     end
+    
+    def engine
+      relation1.engine != relation2.engine ? Memory::Engine.new : relation1.engine
+    end
   end
 
   class InnerJoin  &lt; Join; end
@@ -39,6 +43,10 @@ module Arel
     def attributes
       relation1.externalize.attributes
     end
+    
+    def engine
+      relation1.engine
+    end
   end
 
   class Relation</diff>
      <filename>lib/arel/algebra/relations/operations/join.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,17 +14,34 @@ module Arel
         .insert(@photos[:id] =&gt; 1, @photos[:user_id] =&gt; 1, @photos[:camera_id] =&gt; 6) \
         .insert(@photos[:id] =&gt; 2, @photos[:user_id] =&gt; 2, @photos[:camera_id] =&gt; 42)
     end
-    
-    it 'joins across engines' do
-      @users                                         \
-        .join(@photos)                               \
-          .on(@users[:id].eq(@photos[:user_id]))     \
-        .project(@users[:name], @photos[:camera_id]) \
-      .let do |relation|
-        relation.call.should == [
-          Row.new(relation, ['bryan', '6']),
-          Row.new(relation, ['emilio', '42'])
-        ]
+
+    describe 'when the in memory relation is on the left' do
+      it 'joins across engines' do
+        @users                                         \
+          .join(@photos)                               \
+            .on(@users[:id].eq(@photos[:user_id]))     \
+          .project(@users[:name], @photos[:camera_id]) \
+        .let do |relation|
+          relation.call.should == [
+            Row.new(relation, ['bryan', '6']),
+            Row.new(relation, ['emilio', '42'])
+          ]
+        end
+      end
+    end
+
+    describe 'when the in memory relation is on the right' do
+      it 'joins across engines' do
+        @photos                                        \
+          .join(@users)                                \
+            .on(@users[:id].eq(@photos[:user_id]))     \
+          .project(@users[:name], @photos[:camera_id]) \
+        .let do |relation|
+          relation.call.should == [
+            Row.new(relation, ['bryan', '6']),
+            Row.new(relation, ['emilio', '42'])
+          ]
+        end
       end
     end
   end</diff>
      <filename>spec/arel/engines/memory/integration/joins/cross_engine_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7a51983efc50c8f9092785b1b586f8884dedc01a</id>
    </parent>
  </parents>
  <author>
    <name>Bryan Helmkamp</name>
    <email>bryan@brynary.com</email>
  </author>
  <url>http://github.com/nkallen/arel/commit/44743bed5568b3065e4f9da7972e3ea1d0d9e728</url>
  <id>44743bed5568b3065e4f9da7972e3ea1d0d9e728</id>
  <committed-date>2009-05-17T13:14:28-07:00</committed-date>
  <authored-date>2009-05-17T13:14:28-07:00</authored-date>
  <message>joining across engines in either direction

Conflicts:

	spec/arel/engines/memory/integration/joins/cross_engine_spec.rb</message>
  <tree>a94ba2e964e516e47c7e48e2c746747f6a3f0acd</tree>
  <committer>
    <name>Bryan Helmkamp</name>
    <email>bryan@brynary.com</email>
  </committer>
</commit>
