[sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Tom Dalton
Using SQLAlchemy 0.9. I am writing a server, that's running in gevent. As part of the library code, I am trying to write a session context manager that checks if the session has uncommitted changes when it's exited (this situation represents a logic/programming error, as I expect every server

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Michael Bayer
On Oct 9, 2014, at 6:09 AM, Tom Dalton tom.dal...@fanduel.com wrote: Using SQLAlchemy 0.9. I am writing a server, that's running in gevent. As part of the library code, I am trying to write a session context manager that checks if the session has uncommitted changes when it's exited

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Tom Dalton
On Thursday, 9 October 2014 16:51:49 UTC+1, Michael Bayer wrote: On Oct 9, 2014, at 6:09 AM, Tom Dalton tom.d...@fanduel.com javascript: wrote: Using SQLAlchemy 0.9. I am writing a server, that's running in gevent. As part of the library code, I am trying to write a session

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Michael Bayer
On Oct 9, 2014, at 12:16 PM, Tom Dalton tom.dal...@fanduel.com wrote: Thanks for the reply. I saw the session transaction events stuff but I'm not sure that they help me (correct me if I'm wrong). I believe a transaction will exist if I run *any* query, not just one that modifies data.

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Tom Dalton
Brilliant, the after_flush event sounds like the way to go. I guess my event handlers would be: after_begin: session.info.clean = True after_flush: if new, dirty, deleted: session.info.clean = False after_commit: session.info.clean = True after_rollback: session.info.clean = True

[sqlalchemy] polymorphic trouble when used into a JOIN

2014-10-09 Thread Aurélien C .
Hi, I have a class which represents a table with polymorphic enabled. When I directly access to this table the polymorphic mechanism adds the needed condition and everything works perfectly. However when this table is joined to a request the condition is missing… I attached a quick sample to

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2014-10-09 Thread Michael Bayer
that should have you covered i think On Oct 9, 2014, at 1:34 PM, Tom Dalton tom.dal...@fanduel.com wrote: Brilliant, the after_flush event sounds like the way to go. I guess my event handlers would be: after_begin: session.info.clean = True after_flush: if new, dirty, deleted:

Re: [sqlalchemy] polymorphic trouble when used into a JOIN

2014-10-09 Thread Michael Bayer
On Oct 9, 2014, at 6:45 PM, Aurélien C. aurelien.s.qlalch...@ap2c.com wrote: Hi, I have a class which represents a table with polymorphic enabled. When I directly access to this table the polymorphic mechanism adds the needed condition and everything works perfectly. However when this