thanks a lot for your answer

On Wednesday, July 16, 2014 5:48:29 PM UTC+4, Michael Bayer wrote:
>
>
> On Jul 16, 2014, at 1:29 AM, Pavel Aborilov <abor...@gmail.com 
> <javascript:>> wrote: 
>
> > Hi! 
> > I have two models 
> > 
> > class DB_Object(Base): 
> >     __tablename__ = 'objects' 
> >     id = Column(Integer, primary_key=True) 
> >     name = Column(String(50), unique=True, nullable=False) 
> >     type = Column(String(50), default="object") 
> >     __mapper_args__ = { 'polymorphic_identity': 'object', 
> 'polymorphic_on': type } 
> > 
> > class Contact(DB_Object): 
> >     __tablename__ = 'contacts' 
> >     id = Column(Integer, ForeignKey('objects.id'), primary_key=True) 
> >     enable = Column(Boolean, default=False) 
> >     normal_open = Column(Boolean, default=True) 
> >     cr_enabled = Column(Boolean, default=False) 
> >     __mapper_args__ = {'polymorphic_identity': 'contact'} 
> > 
> > I need to delete group of contacts by id, but 
> > if I do 
> > 
> > ids = (1,2,3) 
> > 
> session.query(Contact).filter(Contact.id.in_(ids)).delete(synchronize_session="fetch")
>  
>
> > 
> > it's remove only contacts and leave object in "objects" table. 
> > 
> > If i remove like this: 
> > o = session.query(Contact).get(id) 
> > session.delete(o) 
> > 
> > it remove objects from both tables. 
> > 
> > How can I do this for group of id? 
>
>
> sorry, I read that completely wrong.   Inheritance.  Yeah, again 
> query.delete() can’t work for an inherited subclass like that.  You’d need 
> to DELETE on the base table and again ON DELETE CASCADE would need to 
> accommodate the child table. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to