You're right ! Thanks On Oct 18, 7:32 pm, Mike Conley <mconl...@gmail.com> wrote: > How are you doing the delete? > > This should delete both. > > a = sess.query(Peripheral).filter(Peripheral.label=='some label').one() > sess.delete(a) > sess.commit() > > This will not work. > > a = sess.query(Peripheral).filter(Peripheral.label=='some > label').delete() > > I think the explanation here is that in this case we are creating an > explicit SQL delete statement without adding Peripheral instances to the > session and so there is no knowledge that a related Actuator exists. Someone > else might be able to give a better explanation. > > -- > Mike Conley > > On Tue, Oct 18, 2011 at 9:03 AM, fribes <fri...@gmail.com> wrote: > > Hi all, > > > Despite some doc and web digging, I didn't find how to tell sqa to behave > > the way I want : > > on deletion on Peripheral, also delete in Actuator. > > > with the following code, the record in Actuator remains after a deletion, > > and a subsequent creation fails with IntegrityError. > > > class Peripheral(Base): > > __tablename__ = 'peripheral' > > id = Column(Integer, primary_key=True) > > label = Column(String(20), nullable=False) > > > __mapper_args__ = {'polymorphic_on': peripheral_type, > > 'polymorphic_identity': 'peripheral'} > > > class Actuator(Peripheral): > > __tablename__ = 'actuator' > > __mapper_args__ = {'polymorphic_identity': 'actuator'} > > id = Column(None, ForeignKey('peripheral.id'), primary_key=True) > > > duration = Column(Integer) > > > Any suggestion ? > > > Regards, > > > -- > > 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 > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/sqlalchemy?hl=en.
-- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.