Hi,

Is there any way to listen for an event for when a query result gets merged 
into a pre-existing object in the session?

I'm working on disabling autoflush for some of our codebase (mostly to cut 
down on queries on a high QPS path), but before doing that I want to write 
a utility to detect when we read data that was flushed via autoflush to cut 
down on any potential bugs.

What I'd like to do is this (while autoflush is still enabled):

table_one = TableOne(name='test')
session.add(table_one) # Track this object as pending a flush via the 
before_* listeners, this is working as expected.

table_two_instances = session.query(TableTwo).all() # All good, doesn't do 
anything with the table_one instance created earlier

table_one_instances = session.query(TableOne).all() # I would like to log a 
warning here as the results of this query depend on a flush happening. What 
I'm hoping to do is detect that one of the rows coming back is the same 
object that was flagged earlier, but I can't see to find the correct event 
to use.

Is this possible? I can't seem to find the appropriate event that would 
trigger when the results from the .all() query get merged back in with the 
existing objects in the session.

Thanks,
Tony

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/13ed894a-0a70-407b-a568-9cc17fd58042n%40googlegroups.com.

Reply via email to