From c933619a0dd427af533854d5d0e3159bb9511d46 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 29 Dec 2007 20:50:32 +0000 Subject: [PATCH] limit scope of try/except --- lib/sqlalchemy/orm/query.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 6f69c9180c..dd7fa638e7 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -855,11 +855,11 @@ class Query(object): raise exceptions.InvalidRequestError("Could not find enough values to formulate primary key for query.get(); primary key columns are %s" % ', '.join(["'%s'" % str(c) for c in self.primary_key_columns])) q = q.params(params) + if lockmode is not None: + q = q.with_lockmode(lockmode) + q = q._select_context_options(populate_existing=bool(refresh_instance), version_check=(lockmode is not None), only_load_props=only_load_props, refresh_instance=refresh_instance) + q._order_by = None try: - if lockmode is not None: - q = q.with_lockmode(lockmode) - q = q._select_context_options(populate_existing=bool(refresh_instance), version_check=(lockmode is not None), only_load_props=only_load_props, refresh_instance=refresh_instance) - q._order_by = None # call using all() to avoid LIMIT compilation complexity return q.all()[0] except IndexError: -- 2.47.3