- Fixed bug where :meth:.Query.get would fail to consistently

raise the :class:`.InvalidRequestError` that invokes when called
on a query with existing criterion, when the given identity is
already present in the identity map. [ticket:2951]
This commit is contained in:
Mike Bayer
2014-02-10 16:33:48 -05:00
parent ab738c21aa
commit 2a25e42c08
3 changed files with 39 additions and 4 deletions
+18
View File
@@ -455,6 +455,24 @@ class GetTest(QueryTest):
# order_by()/get() doesn't raise
s.query(User).order_by(User.id).get(8)
def test_no_criterion_when_already_loaded(self):
"""test that get()/load() does not use preexisting filter/etc. criterion,
even when we're only using the identity map."""
User, Address = self.classes.User, self.classes.Address
s = create_session()
u1 = s.query(User).get(7)
q = s.query(User).join('addresses').filter(Address.user_id==8)
assert_raises(sa_exc.InvalidRequestError, q.get, 7)
assert_raises(sa_exc.InvalidRequestError, s.query(User).filter(User.id==7).get, 19)
# order_by()/get() doesn't raise
s.query(User).order_by(User.id).get(8)
def test_unique_param_names(self):
users = self.tables.users