mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-27 02:52:53 -04:00
- 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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user