From: Mike Bayer Date: Thu, 25 May 2006 15:02:59 +0000 (+0000) Subject: workaround for get that requires multiple ids in the case of joined table inheritance X-Git-Tag: rel_0_2_0~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f50a6f8ebc84f86596a861794dc0a9b9368a05c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git workaround for get that requires multiple ids in the case of joined table inheritance --- diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index cb51da02a8..ef26fee4f7 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -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]