Hey all,

I've got some a polymorphic inheritance structure set up (simple
Parent->Child with joined tables), but the child records aren't
guaranteed to be present all the time.  I know it sorta goes against
the idea of the relationship when the child record is missing, but
there isn't much of a choice (legacy stuff).

I couldn't find any reference on how to make this work.  I'm fine with
it creating a Child instance with only the parent's fields populated
(the child's fields set to None).

I also noticed that you can't change the 'type' column, it'll insert
whatever value identifies it from the mapper (makes sense, though),
and ignores it during updates.  Whats not clear is how do I change the
type, period?  Creating a new child instance and setting its id's to
the parent's doesn't work ("conflicts with persisted instance").  Are
my bleary eyes missing something?

Here's the psuedo code:
parents = Table(Column('id', primary_key), Column('type')) # identity
= "parent"
children = Table(Column('cid', primary_key), Column('pid',
foreign_key)) # identity="child"

# assume there is already parents(id=1, type="parent")
p = session.query(Parent).get(1)
new_child = Child()
new_child.id = p.id
session.save(new_child) # persistence error
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to