From: Mike Bayer Date: Tue, 5 Feb 2008 19:41:51 +0000 (+0000) Subject: expire with synonyms [ticket:964] X-Git-Tag: rel_0_4_3~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b6e2defe593b4df2810df91193a8729ccea8e1c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git expire with synonyms [ticket:964] --- diff --git a/CHANGES b/CHANGES index 0b0d3c3ca1..af9d1d7fb8 100644 --- a/CHANGES +++ b/CHANGES @@ -188,7 +188,7 @@ CHANGES - autoflush for commit() wasn't flushing for simple subtransactions. - - Miscellaneous tickets: [ticket:940] + - Miscellaneous tickets: [ticket:940] [ticket:964] - general - Fixed a variety of hidden and some not-so-hidden diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 84c9dfbb63..8156c441c4 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -72,6 +72,8 @@ class ProxiedAttribute(InstrumentedAttribute): """ class ProxyImpl(object): + accepts_scalar_loader = True + def __init__(self, key): self.key = key diff --git a/test/orm/expire.py b/test/orm/expire.py index 8a01017e41..3394c751bd 100644 --- a/test/orm/expire.py +++ b/test/orm/expire.py @@ -208,7 +208,31 @@ class ExpireTest(FixtureTest): sess.expire(u, ['name', 'addresses']) assert 'name' not in u.__dict__ assert 'addresses' not in u.__dict__ - + + def test_expire_synonym(self): + mapper(User, users, properties={ + 'uname':synonym('name') + }) + + sess = create_session() + u = sess.query(User).get(7) + assert 'name' in u.__dict__ + assert u.uname == u.name + + sess.expire(u) + assert 'name' not in u.__dict__ + + users.update(users.c.id==7).execute(name='jack2') + assert u.name == 'jack2' + assert u.uname == 'jack2' + assert 'name' in u.__dict__ + + # this wont work unless we add API hooks through the attr. system + # to provide "expire" behavior on a synonym + #sess.expire(u, ['uname']) + #users.update(users.c.id==7).execute(name='jack3') + #assert u.uname == 'jack3' + def test_partial_expire(self): mapper(Order, orders)