Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-23 Thread Mike Bayer
On Tue, May 22, 2018 at 2:47 PM, Diego Quintana wrote: > This works! I can't thank you enough! I dived into the source code to > understand what was happening but I did not get much. I really hope I can be > of more help in the future. > > I have one last question, if I

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-22 Thread Mike Bayer
the issue is because the addition of test_parent to child1.parents triggers two individual "dirty" events, which each resolve to the same INSERT operation into the parents_children_relationship table. Normally, these two dirty events are resolved together during the flush process. However, within

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-22 Thread Mike Bayer
On Mon, May 21, 2018 at 4:12 PM, Diego Quintana wrote: > I understand it might be a lot to process, and I really appreciate your > help. To avoid polluting this mailing list with more code I've moved this > question to Stackoverflow at >

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-18 Thread Mike Bayer
On Fri, May 18, 2018 at 9:06 PM, Diego Quintana wrote: > So I watched the video, made a lot of stuff clear. What I'm not certain > about is the symmetry of relationships. > > > I used to think that, in many to many relationships (perhaps for all of the > relationships

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-18 Thread Mike Bayer
On Fri, May 18, 2018 at 4:44 PM, Diego Quintana wrote: > So I'm back to this, and I wonder about something you said: >> >> >> the main complication here is that those "dynamic" relationships >> require that a query runs for everything, which means everything has >> to be in

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-18 Thread Diego Quintana
So I'm back to this, and I wonder about something you said: > > the main complication here is that those "dynamic" relationships > require that a query runs for everything, which means everything has > to be in the database, which means it flushes the session very > aggressively (and also

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-04 Thread Diego Quintana
At the moment I've moved to other features, but I should be back to this somewhere in the near future. I will let you know the results. I really appreciate your time, thanks again. Best, Am Donnerstag, 3. Mai 2018 10:10:47 UTC-3 schrieb Mike Bayer: > > On Thu, May 3, 2018 at 7:39 AM, Diego

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-03 Thread Mike Bayer
On Thu, May 3, 2018 at 7:39 AM, Diego Quintana wrote: > Thanks again for your reply > >> at the core is that when you remove a child from the parent in the >> _remove_pets event, you want to prevent the _remove_children() event >> from actually happening, I think. > > >

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-03 Thread Diego Quintana
Just wanted to note something, I tried to work on an implementation here which would also have to be > extremely clever but I realized I don't actually understand what this > is supposed to do. > > *if "remove child from parent" has two different flavors then there needs > to be all kinds of

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-03 Thread Diego Quintana
Thanks again for your reply at the core is that when you remove a child from the parent in the > _remove_pets event, you want to prevent the _remove_children() event > from actually happening, I think. > Yes, since it is a different usage case or flavour. I was trying to pass kwargs to the event

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-02 Thread Mike Bayer
On Wed, May 2, 2018 at 12:22 PM, Diego Quintana wrote: > Hello, thanks again for your help. I'm not sure I understand what you said > totally, and I believe this is the most simple MCVE I can provide. > > My local tests use postgresql, but I'm setting an in-memory sqlite3

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-02 Thread Diego Quintana
Hello, thanks again for your help. I'm not sure I understand what you said totally, and I believe this is the most simple MCVE I can provide. My local tests use postgresql, but I'm setting an in-memory sqlite3 engine here. I'm not fond of the differences between two backends, but the tests run

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-02 Thread Mike Bayer
On Wed, May 2, 2018 at 10:14 AM, Diego Quintana wrote: > This worked. > > I'm trying to achieve some rather tricky behaviour, where > > Adding a children to some parent will also add the child's pets to the > parent > Removing a children from some parent will also remove

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-05-02 Thread Diego Quintana
This worked. I'm trying to achieve some rather tricky behaviour, where 1. Adding a children to some parent will also add the child's pets to the parent 2. Removing a children from some parent will also remove every current relationship that the Parent has with such pet 3. If

Re: [sqlalchemy] How to override append and remove methods used in orm.relationships

2018-04-26 Thread Mike Bayer
On Thu, Apr 26, 2018 at 11:04 AM, Diego Quintana wrote: > Hello. > > Say I have three tables in a declarative fashion, `Parent`, `Child`, and > `Pet`, in such way that > > * `Parent` has a many-to-many relationship with both `Child` and `Pet`, > meaning that a Parent can

[sqlalchemy] How to override append and remove methods used in orm.relationships

2018-04-26 Thread Diego Quintana
Hello. Say I have three tables in a declarative fashion, `Parent`, `Child`, and `Pet`, in such way that * `Parent` has a many-to-many relationship with both `Child` and `Pet`, meaning that a Parent can own a Child and its pets, and also a Pet without its Child. * `Child` has a one-to-many