Mike Bayer committed 87813c7

added 'noninherited table' prop to mapper indicating the "lead" table, in the case of
inheritance. relations now create priamry/secondary joins against that lead table. if you want to create it against
an inherited table, use explicit join conditions.
added 'correlate' argument to CompoundSelect to get polymorph example working again.

Comments (0)

Files changed (6)

 - completed "post_update" feature, will add a second update statement before inserts
 and after deletes in order to reconcile a relationship without any dependencies


 # extend from a common base class, although this same approach can be used
 # with 
-#db = create_engine('sqlite://', echo=True, echo_uow=False)
-db = create_engine('postgres://user=scott&password=tiger&host=', echo=True, echo_uow=False)
+db = create_engine('sqlite://', echo=True, echo_uow=False)
+#db = create_engine('postgres://user=scott&password=tiger&host=', echo=True, echo_uow=False)
 # a table to store companies
 companies = Table('companies', db, 


             self._synchronizer = sync.ClauseSynchronizer(self, self, sync.ONETOMANY)
             self._synchronizer.compile(self.table.onclause, inherits.tables, TableFinder(table))
             self.inherits = inherits
+            self.noninherited_table = table
             self.primarytable = self.table
+            self.noninherited_table = self.table
             self._synchronizer = None
             self.inherits = None


         # if join conditions were not specified, figure them out based on foreign keys
         if self.secondary is not None:
             if self.secondaryjoin is None:
-                self.secondaryjoin = sql.join(, self.secondary).onclause
+                self.secondaryjoin = sql.join(self.mapper.noninherited_table, self.secondary).onclause
             if self.primaryjoin is None:
-                self.primaryjoin = sql.join(parent.table, self.secondary).onclause
-            tf = mapper.TableFinder(self.secondaryjoin, check_columns=True)
-            tf2 = mapper.TableFinder(self.primaryjoin, check_columns=True)
-            for t in tf2:
-                if t is not self.secondary and t in tf:
-                    raise ArgumentError("Ambiguous join conditions generated between '%s' and '%s' (primaryjoin='%s', secondaryjoin='%s'); please specify explicit primaryjoin and/or secondaryjoin arguments to property '%s'" % (,, self.primaryjoin, self.secondaryjoin, self.key))
+                self.primaryjoin = sql.join(parent.noninherited_table, self.secondary).onclause
             if self.primaryjoin is None:
-                self.primaryjoin = sql.join(parent.table,
+                self.primaryjoin = sql.join(parent.noninherited_table,
         # if the foreign key wasnt specified and theres no assocaition table, try to figure
         # out who is dependent on who. we dont need all the foreign keys represented in the join,
         # just one of them.  


         self.selects = selects
         self.use_labels = kwargs.pop('use_labels', False)
         self.parens = kwargs.pop('parens', False)
+        self.correlate = kwargs.pop('correlate', False)
         self.oid_column = selects[0].oid_column
         for s in self.selects:


-        Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar,,, lazy=False))
-        #Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar, lazy=False))
+        #Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar,,, lazy=False))
+        Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar, lazy=False))
         b = Bar('barfoo')
                 return "Bar id %d, data %s" % (,
         Bar.mapper = mapper(Bar, bar, inherits=Foo.mapper, properties={
-        'foos' :relation(Foo.mapper, bar_foo,, lazy=False)
-#        'foos' :relation(Foo.mapper, bar_foo, lazy=True)
+        #'foos' :relation(Foo.mapper, bar_foo,, lazy=False)
+        'foos' :relation(Foo.mapper, bar_foo, lazy=True)
         b = Bar('bar #1')
                 return "Blub id %d, data %s, bars %s, foos %s" % (,, repr([b for b in self.bars]), repr([f for f in self.foos]))
         Blub.mapper = mapper(Blub, blub, inherits=Bar.mapper, properties={
-            'bars':relation(Bar.mapper, blub_bar,, lazy=False),
-            'foos':relation(Foo.mapper, blub_foo,, lazy=False),
+#            'bars':relation(Bar.mapper, blub_bar,, lazy=False),
+#            'foos':relation(Foo.mapper, blub_foo,, lazy=False),
+            'bars':relation(Bar.mapper, blub_bar, lazy=False),
+            'foos':relation(Foo.mapper, blub_foo, lazy=False),
         useobjects = True
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.