[Sqlalchemy-tickets] [sqlalchemy] #2787: History state after commit
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-07-19 10:12:12
|
#2787: History state after commit
--------------------------------+-----------------------------------------
Reporter: harutune | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Keywords: history attributes | Progress State: awaiting triage
--------------------------------+-----------------------------------------
We are doing some stuff with history and have a little problem.
After commit, history has been reseted to empty state: there no value in
`unchanged` and after attribute is changed there is no value in `deleted`.
Probably, it is a bug. If it is correct behaviour, how is it expained?
Both on 0.8.2 and dev versions. Here is a test case.
{{{
class HistoryTest(_fixtures.FixtureTest):
run_inserts = None
def test_commit_history(self):
from sqlalchemy.orm.attributes import get_history, History
User, users = self.classes.User, self.tables.users
m2 = sa.MetaData()
users_unbound = users.tometadata(m2)
mapper(User, users_unbound)
sess = Session(binds={User: self.metadata.bind})
u = User(id=1, name='daniel')
sess.add(u)
print get_history(u, 'name')
assert get_history(u, 'name') ==\
History(['daniel'], (), ())
sess.commit()
print get_history(u, 'name')
assert get_history(u, 'name') == \
History((), ['daniel'], ())
# fails: History((), (), ())
u.name = 'peter'
print get_history(u, 'name')
assert get_history(u, 'name') == \
History(['peter'], (), ['daniel'])
# fails: History(['peter'], (), ())
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2787>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|