]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
workaround for get that requires multiple ids in the case of joined table inheritance
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 25 May 2006 15:02:59 +0000 (15:02 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 25 May 2006 15:02:59 +0000 (15:02 +0000)
lib/sqlalchemy/orm/query.py

index cb51da02a8a2bd0ba37ccae18769d22602586d58..ef26fee4f7963f88f93f8c76b3b220ac3d9d278b 100644 (file)
@@ -267,7 +267,13 @@ class Query(object):
         params = {}
         for primary_key in self.mapper.pks_by_table[self.table]:
             params["pk_"+primary_key.key] = ident[i]
-            i += 1
+            # if there are not enough elements in the given identifier, then 
+            # use the previous identifier repeatedly.  this is a workaround for the issue 
+            # in [ticket:185], where a mapper that uses joined table inheritance needs to specify
+            # all primary keys of the joined relationship, which includes even if the join is joining
+            # two primary key (and therefore synonymous) columns together, the usual case for joined table inheritance.
+            if len(ident) > i + 1:
+                i += 1
         try:
             statement = self._compile(self._get_clause)
             return self._select_statement(statement, params=params, populate_existing=reload)[0]