6 Sep 19:21
Selectable mapping fails in polymorphic schema?
From: Jason Yamada-Hanff <jyamada1 <at> gmail.com>
Subject: Selectable mapping fails in polymorphic schema?
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-09-06 17:24:58 GMT
Subject: Selectable mapping fails in polymorphic schema?
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-09-06 17:24:58 GMT
Below is a simplified case of a problem (bug?) I am running into. I have a polymorphic schema using joined-table inheritance. In my OO layer, a Group is an Agent, and a Lab is a Group. In the DB layer, Lab doesn't actually need to hold any extra information so it doesn't need a separate table. Instead, I would like to map the Lab object to the 'groups' table and select only those types that are identified as a lab by the 'type' discriminator column in 'agents' table. I want,t hen, to map Lab to a selectable. However, when I try to create and flush a Lab instance with the setup below, it is obvious that the attributes that should map into the groups table aren't getting collected into the INSERT statement correctly. If I change `lab_select` to the simple join without the select statement, the Lab instance is persisted correctly. Of course, this does nothing for the need to filter out non-lab entries. Similarly, if I create a useless extra table called `labs` and map to that instead, the INSERT works Any ideas on how to adjust the `lab_select` statement below so that this works? Thanks! -Jason ---- import sqlalchemy as sa(Continue reading)
Traceback (most recent call last):
File "foo.py", line 38, in <module>
DBSession.flush()
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/scoping.py",
line 106, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/session.py",
line 1409, in flush
flush_context.execute()
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/
unitofwork.py", line 265, in execute
UOWExecutor().execute(self, tasks)
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/
unitofwork.py", line 753, in execute
self.execute_save_steps(trans, task)
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/
unitofwork.py", line 771, in execute_save_steps
self.execute_dependencies(trans, task, True)
File "/Users/michael/programming/rumdemo3/lib/python2.5/site-
packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/
unitofwork.py", line 783, in execute_dependencies
self.execute_dependency(trans, dep, True)
RSS Feed