On 9/22/15 1:52 PM, Jonathan Vanasco wrote:
This is, admittedly, an abuse of SqlAlchemy. I'm wondering if anyone
else has dealt with this situation before and how they handled it.
We have a handful of situations where SqlAlchemy generates a raw sql
update against a table. Something like
_table = model.Foo.__table__
session.execute(_table.update().where(_table.c.id ==
foo_id).values(_table.c.count_a = (_table.c.count_a + 1)))
This is done because we may or may-not have the instance of
Foo(foo_id) loaded, and it doesn't make sense to load if not already
present.
What I'm wondering is this:
has anyone in a similar situation looked at using events or other
hooks to inspect the current session cache and update the objects if
they have been loaded? [as well as marking the attribute as clean --
since it already will have updated on the database]
well that's what query.update() does. you can run the same query as
above via that system.
--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.