]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
tweak to mapper to allow inheritance on the same table.
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 27 Mar 2006 02:58:20 +0000 (02:58 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 27 Mar 2006 02:58:20 +0000 (02:58 +0000)
CHANGES
lib/sqlalchemy/mapping/mapper.py

diff --git a/CHANGES b/CHANGES
index a996bd5647486ff6264f1b6e14acb0156ea92acd..e454a4e65a4e6b114a09afa06c35207299b2dce8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -31,6 +31,8 @@ commit
 concept of relations on a mapper being made towards the "local" table for that
 mapper, not the tables it inherits.  allows more complex compositional patterns
 to work with lazy/eager loading.
+- added support for mappers to inherit from others based on the same table, 
+just specify the same table as that of both parent/child mapper.
 - some minor speed improvements to the attributes system with regards to 
 instantiating and populating new objects. 
 - fixed MySQL binary unit test
index ed07983e440819b2a7461db0d5e239b783a5c550..a0de86df4f8b12b03033afee0dc217d5a37e4424 100644 (file)
@@ -71,22 +71,24 @@ class Mapper(object):
         if inherits is not None:
             self.primarytable = inherits.primarytable
             # inherit_condition is optional.
-            if inherit_condition is None:
-                # figure out inherit condition from our table to the immediate table
-                # of the inherited mapper, not its full table which could pull in other 
-                # stuff we dont want (allows test/inheritance.InheritTest4 to pass)
-                inherit_condition = sql.join(inherits.noninherited_table, table).onclause
-            self.table = sql.join(inherits.table, table, inherit_condition)
-            #print "inherit condition", str(self.table.onclause)
-
-            # generate sync rules.  similarly to creating the on clause, specify a 
-            # stricter set of tables to create "sync rules" by,based on the immediate
-            # inherited table, rather than all inherited tables
-            self._synchronizer = sync.ClauseSynchronizer(self, self, sync.ONETOMANY)
-            self._synchronizer.compile(self.table.onclause, util.HashSet([inherits.noninherited_table]), TableFinder(table))
-            # the old rule
-            #self._synchronizer.compile(self.table.onclause, inherits.tables, TableFinder(table))
+            if not table is inherits.noninherited_table:
+                if inherit_condition is None:
+                    # figure out inherit condition from our table to the immediate table
+                    # of the inherited mapper, not its full table which could pull in other 
+                    # stuff we dont want (allows test/inheritance.InheritTest4 to pass)
+                    inherit_condition = sql.join(inherits.noninherited_table, table).onclause
+                self.table = sql.join(inherits.table, table, inherit_condition)
+                #print "inherit condition", str(self.table.onclause)
 
+                # generate sync rules.  similarly to creating the on clause, specify a 
+                # stricter set of tables to create "sync rules" by,based on the immediate
+                # inherited table, rather than all inherited tables
+                self._synchronizer = sync.ClauseSynchronizer(self, self, sync.ONETOMANY)
+                self._synchronizer.compile(self.table.onclause, util.HashSet([inherits.noninherited_table]), TableFinder(table))
+                # the old rule
+                #self._synchronizer.compile(self.table.onclause, inherits.tables, TableFinder(table))
+            else:
+                self._synchronizer = None
             self.inherits = inherits
             self.noninherited_table = table
         else: