From: Mike Bayer Date: Sat, 29 Dec 2007 20:50:32 +0000 (+0000) Subject: limit scope of try/except X-Git-Tag: rel_0_4_2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c933619a0dd427af533854d5d0e3159bb9511d46;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git limit scope of try/except --- 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: