Re: [sqlalchemy] delete orphan unfavorite operations

2019-03-08 Thread Mike Bayer
On Fri, Mar 8, 2019 at 3:05 PM Conferency wrote: > > Thanks. > > I didn't use association proxy. > > > "because you can't add Tool to Person.tools". This is real code and I can > > directly append the tool instance. that will cause this error: sqlalchemy.orm.exc.FlushError: Attempting to flush

Re: [sqlalchemy] delete orphan unfavorite operations

2019-03-08 Thread Conferency
Thanks. I didn't use association proxy. > "because you can't add Tool to Person.tools". This is real code and I can directly append the tool instance. class Association(db.Model): ... id = db.Column(Integer, primary_key=True, index=True) tool_id = db.Column(Integer, ForeignKey('tool

Re: [sqlalchemy] delete orphan unfavorite operations

2019-03-08 Thread Mike Bayer
On Thu, Mar 7, 2019 at 4:46 PM Conferency wrote: > > Hi, I have 3 classes: two have many to many relationship between them, one is > association class. > > class Person: > ... > tools = relationship('Association', back_populates='user', lazy=True, > cascade='all, delete-orphan') > > clas

[sqlalchemy] delete orphan unfavorite operations

2019-03-07 Thread Conferency
Hi, I have 3 classes: two have many to many relationship between them, one is association class. class Person: ... tools = relationship('Association', back_populates='user', lazy=True, cascade='all, delete-orphan') class Tool: ... users = relationship('Association', back_populate