Hi,
I read carefully the documentation at
http://www.sqlalchemy.org/docs/orm/inheritance.html and I'd like to
implement a similar joined table inheritance for my application.
The following example is provided :
*mapper(Employee, employees, polymorphic_on=employees.c.type,
I'm trying to reply myself... maybe I could set *polymorphic_identity=None *at
the Employee level, and define the DB field EMPLOYEE.TYPE field as not
nullable...
Would that work ? Is there a better way ?
Thanks !
Franck
On Thu, Mar 10, 2011 at 2:00 PM, Franck franck.pe...@gmail.com wrote:
Hi,
Or just leave the polymorphic_entity='employee' and put a CHECK
constraint on the table enforcing that the value of that column is not
'employee'. Or just don't code anything that can add a generic
employee :)
On Mar 10, 8:23 am, Franck franck.pe...@gmail.com wrote:
I'm trying to reply
I make occasional use of alternate collection classes for my
sqlalchemy relationships. For example, column_mapped_collection. The
existing collection classes in sqlalchemy.orm.collections work really
well for me; I have a lot of relational data that very naturally
belongs in dicts rather than
Ach, I did it again... proceeded as if column_mapped_collection and
attribute_mapped_collection provide collection classes that are dicts
of lists. No, they're just dicts of scalar values!
Again and again I need dicts of lists. They seem to really fit the
data that I tend to work with; A's
So, jek, if you're listening, or anyone else -- is there an already
existing, working implementation of a Dict of Lists or Dict of Sets
collection class?
On Mar 10, 1:55 pm, Eric Ongerth ericonge...@gmail.com wrote:
Ach, I did it again... proceeded as if column_mapped_collection and
However in my case I don't want to be able to persist some random Employee.
All my employees should be engineers or managers. Ideally some exception
should be thrown if I try to add an Employee object to my session.
Maybe something like this. But I'm not sure if it's the right way. It fails
class EmployeeChecker(MapperExtension):
def before_insert(self, mapper, connection, target):
if type(target) != Employee:
Must be ==
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to