.. include:: changelog_07.rst
:start-line: 5
+.. changelog::
+ :version: 1.0.1
+
+ .. change::
+ :tags: bug, orm
+ :tickets: 3368
+
+ Fixed a critical regression caused by :ticket:`3061` where the
+ NEVER_SET symbol could easily leak into a lazyload query, subsequent
+ to the flush of a pending object. This would occur typically
+ for a many-to-one relationship that does not use a simple
+ "get" strategy. The good news is that the fix improves efficiency
+ vs. 0.9, because we can now skip the SELECT statement entirely
+ when we detect NEVER_SET symbols present in the parameters; prior to
+ :ticket:`3061`, we couldn't discern if the None here were set or not.
+
+
.. changelog::
:version: 1.0.0
:released: April 16, 2015
import re
from .base import instance_str, state_str, state_class_str, attribute_str, \
- state_attribute_str, object_mapper, object_state, _none_set
+ state_attribute_str, object_mapper, object_state, _none_set, _never_set
from .base import class_mapper, _class_to_mapper
from .base import InspectionAttr
from .path_registry import PathRegistry
run_inserts = None
- def _u_ad_fixture(self, populate_user):
+ def _u_ad_fixture(self, populate_user, dont_use_get=False):
users, Address, addresses, User = (
self.tables.users,
self.classes.Address,
self.classes.User)
mapper(User, users, properties={
- 'addresses': relationship(Address, backref='user')
+ 'addresses': relationship(Address, back_populates='user')
+ })
+ mapper(Address, addresses, properties={
+ 'user': relationship(
+ User,
+ primaryjoin=and_(
+ users.c.id == addresses.c.user_id, users.c.id != 27)
+ if dont_use_get else None,
+ back_populates='addresses'
+ )
})
- mapper(Address, addresses)
sess = create_session()
a1 = Address(email_address='a1')
sess.expire_all()
return User, Address, sess, a1
+ def test_no_use_get_params_missing(self):
+ User, Address, sess, a1 = self._u_ad_fixture(False, True)
+
+ def go():
+ eq_(a1.user, None)
+
+ # doesn't emit SQL
+ self.assert_sql_count(
+ testing.db,
+ go,
+ 0
+ )
+
def test_get_empty_passive_return_never_set(self):
User, Address, sess, a1 = self._u_ad_fixture(False)
eq_(