From: Mike Bayer Date: Thu, 13 May 2010 19:45:56 +0000 (-0400) Subject: - Added internal warning in case an instance without a X-Git-Tag: rel_0_6_1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0fa460791735cd27dc41b1ed154465ea2441be5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Added internal warning in case an instance without a full PK happened to be expired and then was asked to refresh. [ticket:1797] --- diff --git a/CHANGES b/CHANGES index 5762bd68ec..61cec42d25 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,10 @@ CHANGES fail during deserialize where parent InstanceState not yet unserialized. [ticket:1802] + - Added internal warning in case an instance without a + full PK happened to be expired and then was asked + to refresh. [ticket:1797] + - sql - expr.in_() now accepts a text() construct as the argument. Grouping parenthesis are added automatically, i.e. usage diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index aec7794f31..a0f234057c 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -2095,6 +2095,15 @@ def _load_scalar_attributes(state, attribute_names): else: identity_key = mapper._identity_key_from_state(state) + if (_none_set.issubset(identity_key) and \ + not mapper.allow_partial_pks) or \ + _none_set.issuperset(identity_key): + util.warn("Instance %s to be refreshed doesn't " + "contain a full primary key - can't be refreshed " + "(and shouldn't be expired, either)." + % state_str(state)) + return + result = session.query(mapper)._get( identity_key, refresh_state=state,