summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-03-16 10:36:48 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-03-16 10:36:48 -0400
commite93ca97baee6b64baf3115259e7e1a8ec05dfced (patch)
tree66c1adac5372392ac467f32aa41732d8e0ed7528 /lib/sqlalchemy/engine/base.py
parentdbaa3627b6aae5fe5567f189664040a485f34064 (diff)
downloadsqlalchemy-e93ca97baee6b64baf3115259e7e1a8ec05dfced.tar.gz
- Added accessors to ResultProxy "returns_rows", "is_insert"
[ticket:2089]
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 972b06ce8..e88ad8265 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -2468,6 +2468,32 @@ class ResultProxy(object):
"""
return self._saved_cursor.lastrowid
+ @property
+ def returns_rows(self):
+ """True if this :class:`.ResultProxy` returns rows.
+
+ I.e. if it is legal to call the methods
+ :meth:`~.ResultProxy.fetchone`,
+ :meth:`~.ResultProxy.fetchmany`
+ :meth:`~.ResultProxy.fetchall`.
+
+ """
+ return self._metadata is not None
+
+ @property
+ def is_insert(self):
+ """True if this :class:`.ResultProxy` is the result
+ of a executing an expression language compiled
+ :func:`.expression.insert` construct.
+
+ When True, this implies that the
+ :attr:`inserted_primary_key` attribute is accessible,
+ assuming the statement did not include
+ a user defined "returning" construct.
+
+ """
+ return self.context.isinsert
+
def _cursor_description(self):
"""May be overridden by subclasses."""