summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-12-21 16:44:12 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-12-21 16:44:12 +0000
commit75d7d8d5105cbdeb9d3bfcccc7b7f08e217f2f7f (patch)
tree4b208c7e3ff4cf08dafa4cdb184718873684fd52
parent90c3944dacad5c1ebb023d6fa2abb95d8ac0dda4 (diff)
downloadsqlalchemy-75d7d8d5105cbdeb9d3bfcccc7b7f08e217f2f7f.tar.gz
added assertion for expiry's current inability to detect a PK switch in the DB
-rw-r--r--test/orm/naturalpks.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/orm/naturalpks.py b/test/orm/naturalpks.py
index 069aea0b3..2a8bead05 100644
--- a/test/orm/naturalpks.py
+++ b/test/orm/naturalpks.py
@@ -51,6 +51,32 @@ class NaturalPKTest(ORMTest):
sess.clear()
u1 = sess.query(User).get('ed')
self.assertEquals(User(username='ed', fullname='jack'), u1)
+
+ def test_expiry(self):
+ mapper(User, users)
+
+ sess = create_session()
+ u1 = User(username='jack', fullname='jack')
+
+ sess.save(u1)
+ sess.flush()
+ assert sess.get(User, 'jack') is u1
+
+ users.update(values={u1.c.username:'jack'}).execute(username='ed')
+
+ try:
+ # expire/refresh works off of primary key. the PK is gone
+ # in this case so theres no way to look it up. criterion-
+ # based session invalidation could solve this [ticket:911]
+ sess.expire(u1)
+ u1.username
+ assert False
+ except exceptions.InvalidRequestError, e:
+ assert "Could not refresh instance" in str(e)
+
+ sess.clear()
+ assert sess.get(User, 'jack') is None
+ assert sess.get(User, 'ed').fullname == 'jack'
@testing.unsupported('sqlite','mysql')
def test_onetomany_passive(self):