Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread Mike Bayer
Seems that way. Careful testing will as always confirm the methodology and implementation. On 09/26/2016 06:29 PM, HP3 wrote: Thank you! So, the following is all true? Recap'ing the solution (Jason's and yours combined): 1- On `after_flush`, call `history_meta.create_version()`

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread HP3
Agreed! Thank you very much again! -- 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

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread HP3
Thank you! So, the following is all true? Recap'ing the solution (Jason's and yours combined): 1- On `after_flush`, call `history_meta.create_version()` for each object that is changing so its `XYZHistory` instance is created and can be stored within `session.info`. 2. On `before_commit`, do

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread Mike Bayer
On 09/26/2016 01:24 PM, HP3 wrote: It seems like 0.9 does not have 'parent' in `SessionTransaction`. Instead, it has `_parent`. Would `_parent` suffice? yes, use _parent. i pushed up docs to 1.0 and 1.1 which indicate that _parent is the original attribute in the absense of .parent.

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread HP3
It seems like 0.9 does not have 'parent' in `SessionTransaction`. Instead, it has `_parent`. Would `_parent` suffice? On Monday, September 26, 2016 at 12:09:55 PM UTC-5, HP3 wrote: > > Thank you Mike, > > So basically, I should move the cleanup from > `after_commit`/`after_rollback` to

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-26 Thread HP3
Thank you Mike, So basically, I should move the cleanup from `after_commit`/`after_rollback` to `after_transaction_end` and do it **only** if `transaction.parent is None`? Recap'ing the solution (Jason's and yours combined): 1- On `after_flush`, call `history_meta.create_version()` for each

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread Mike Bayer
On 09/23/2016 04:24 PM, HP3 wrote: I just tried cleaning up at `after_transaction_end` but the whole history stopped working. It seems like `after_transaction_create`/`after_transaction_end` surrounds the loading of a one-to-many relationship.Thus, when `after_commit` happened, the

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
I just tried cleaning up at `after_transaction_end` but the whole history stopped working. It seems like `after_transaction_create`/`after_transaction_end` surrounds the loading of a one-to-many relationship.Thus, when `after_commit` happened, the `history_objects` dict had being emptied

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
Thank you Mike! At this point, I am cleaning session.info["history-objects"] in 'after_commit' and 'after_rollback'. I was wondering about 'after_soft_rollback` too ... (I discovered that history objects were being "re-added" when I was issuing session.rollback() so I added the cleanup there

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread Mike Bayer
On 09/23/2016 10:18 AM, HP3 wrote: Hello all, Couple of weeks back (see [*]), while discussing that history_meta.py performs an update and an insert for each session.dirty object whenever session.flush() happens, Simon suggested the following solution to coalesce all changes within the same

[sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
Hello all, Couple of weeks back (see [*]), while discussing that history_meta.py performs an update and an insert for each session.dirty object whenever session.flush() happens, Simon suggested the following solution to coalesce all changes within the same transaction into a single insert and