From: Mike Bayer Date: Sat, 23 Sep 2006 23:03:50 +0000 (+0000) Subject: descriptive error message when an executioncontext-requiring call is called off a... X-Git-Tag: rel_0_3_0~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66a152bb77d226f3dd0a09581e2aea9bfeb28c2b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git descriptive error message when an executioncontext-requiring call is called off a ResultProxy which was created via literal statement execution and therefore does not have an execution context. --- diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 1285e8490d..3382a42175 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -540,13 +540,13 @@ class ResultProxy: self.cursor = cursor self.engine = engine self.closed = False - self.executioncontext = executioncontext - self.echo = engine.echo=="debug" - self.__key_cache = {} - if executioncontext: + if executioncontext is not None: + self.__executioncontext = executioncontext self.rowcount = executioncontext.get_rowcount(cursor) else: self.rowcount = cursor.rowcount + self.echo = engine.echo=="debug" + self.__key_cache = {} metadata = cursor.description self.props = {} self.keys = [] @@ -566,6 +566,13 @@ class ResultProxy: self.keys.append(colname) self.props[i] = rec i+=1 + def _executioncontext(self): + try: + return self.__executioncontext + except AttributeError: + raise exceptions.InvalidRequestError("This ResultProxy does not have an execution context with which to complete this operation. Execution contexts are not generated for literal SQL execution.") + executioncontext = property(_executioncontext) + def close(self): if not self.closed: self.closed = True