some confusion, the sort order on my local machine produces "Person
Joe Smith" for employees[0], producing the base non-inheriting mapper
so the test was working. also, your patch fails on my machine and
theres no "id" variable so that fails too.
but anyway, there was an additional glitch with the bind parameter
names colliding in the _get() method, that is fixed in 1511.
the full fix is:
Index: lib/sqlalchemy/orm/query.py
===================================================================
--- lib/sqlalchemy/orm/query.py (revision 1507)
+++ lib/sqlalchemy/orm/query.py (revision 1511)
@@ -24,7 +24,7 @@
if not hasattr(mapper, '_get_clause'):
_get_clause = sql.and_()
for primary_key in self.mapper.pks_by_table[self.table]:
- _get_clause.clauses.append(primary_key ==
sql.bindparam("pk_"+primary_key.key))
+ _get_clause.clauses.append(primary_key ==
sql.bindparam("pk_"+primary_key._label))
self.mapper._get_clause = _get_clause
self._get_clause = self.mapper._get_clause
def _get_session(self):
@@ -266,8 +266,14 @@
i = 0
params = {}
for primary_key in self.mapper.pks_by_table[self.table]:
- params["pk_"+primary_key.key] = ident[i]
- i += 1
+ params["pk_"+primary_key._label] = ident[i]
+ # 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]
On May 25, 2006, at 1:56 PM, jürgen Kartnaller wrote:
Hello Michael.
Your change saves the application to crash but it doesn't give back
the
object.
Attached I have a diff for an extended test.
Jürgen
And sorry for the bad subject :(
Michael Bayer wrote:
this is a known issue in ticket 185; youd have to call get
([employee_id,
employee_id]). I have just committed a very small hack in 1508
that
will work around this, though (by making an assumption about the
given
id), so give that a try.
On May 25, 2006, at 8:28 AM, jürgen Kartnaller wrote:
employee_id = c.employees[0].person_id
+ employee_cls = c.employees[0].__class__
+
+ session.flush()
+ session.clear()
+
+ e = session.query(Person).get(employee_id)
+ e = session.query(employee_cls).get(employee_id)
+
+ c = session.query(Company).get(id)
+
--
---------------------------------------------------
Jürgen Kartnaller mailto:juergen_at_kartnaller.at
http://www.kartnaller.at
http://www.mcb-bregenz.at
---------------------------------------------------
Index: polymorph.py
===================================================================
--- polymorph.py (Revision 1509)
+++ polymorph.py (Arbeitskopie)
@@ -161,6 +161,19 @@
for e in c.employees:
print e, e._instance_key
+ employee_id = c.employees[0].person_id
+ employee_cls = c.employees[0].__class__
+
+ session.flush()
+ session.clear()
+
+ e = session.query(Person).get(employee_id)
+ assert e is not None
+ e = session.query(employee_cls).get(employee_id)
+ assert e is not None
+
+ c = session.query(Company).get(id)
+
session.delete(c)
session.flush()
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users