Re: [Sqlalchemy-tickets] [sqlalchemy] #2787: History state after commit
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-07-19 15:34:21
|
#2787: History state after commit
----------------------------------+------------------------------------
Reporter: harutune | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Resolution: | Keywords: history attributes
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by zzzeek):
well the value there is expired after a commit, to get it back would
normally be by refreshing from the database (i.e. if you say `u.name`, it
will load it).
The history functions were written first and foremost as the system by
which the ORM does what it needs to do in order to flush changes. At a
certain point, we began publishing these functions for general use, as
they are very useful for lots of things, but a lot of behaviors that are
by design such as this one don't apply so well to the outside world where
more consistent behavior is desirable. Historically, the functions are
tailored towards answering the question, "has anything changed?", and if
not, then we don't care what value is actually there or not. In
particular the whole system is designed to minimize database calls as much
as possible.
So it is a bug in terms of the public API and it is by design in terms of
the internals. However, there is a system by which whether or not it
should load from the database is determined, and that's the "passive"
flag. It defaults to PASSIVE_OFF, which means, "go out to the database
and everything else, it's fine". So here we can make that change using
the attached patch. But also there's a bit of cleanup still needed in
terms of some of the return codes used by the system internally, i.e.
NEVER_SET vs. NO_VALUE vs. PASSIVE_NO_RESULT, these could probably use
another pass.
For the time being, just say "getattr(obj, attrname)" before you call
get_history(), as I want further changes to the attribute system to be for
0.9.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2787#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|