On Wed, Jan 16, 2019 at 4:34 PM Gmoney <grgg...@gmail.com> wrote: > > It appears that > > flush_context.execute() > > > Is the step that determines the FK id of the relationship object and sets > that FK id value on the base object. But then it wipes the session's > attribute history, as it's been flushed to the DB. Wondering if there's a > way to trigger this operation without flushing, so I can interrogate the > object and see that that FK id was changed (has a history).
not unless you use event hooks to inspect things as they change. Feel free to share details regarding what you actually need to accomplish and why. > > > On Wednesday, January 16, 2019 at 4:18:36 PM UTC-5, Gmoney wrote: >> >> I was having a heck of confusing time debugging some code where I was trying >> to determine what attrs on an ORM changed prior to committing it. Every >> time in my debugger I'd be getting different results (w/r to History). I >> finally realized that autoflush was enabled, and now that I disabled it, >> things seem much more sane. The strange part though, is that the >> update/flush would occur randomly while I was just iterating through some >> mapper attributes checking History. No queries, no nothing... but at one >> point... whoosh... it must have flushed. >> >> I'm basing the 'has flushed' inference on the fact that my test update is >> updating a foreign key relationship. I update the relationship object (not >> the ID) on the primary object. At that point, the FK id is still the old id >> from prior to the change. Only when I Flush, does the id get updated >> automatically. Well I watch that ID in a debug watch, and boom... it just >> randomly updates at some point when I'm walking through unrelated fields >> checking for history (not issuing any querys or session activity, as far as >> I can tell). >> >> Just looking for a sanity check if this behavior seems to make sense? I >> would have thought the auto flushing would happen inline with a query... >> like you step over that query or operation, and the autoflush occurs >> synchronously. This is not what I'm seeing. > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > 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 https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.