diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-01-27 23:56:13 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-01-27 23:56:13 +0000 |
commit | d917119235e7b43413e9b191492e0f5f48425cb0 (patch) | |
tree | 6f4cc383dbbb20bb10a7a2f8027997b6305a6f01 /lib/sqlalchemy/sql.py | |
parent | 3a5409780dcaa198884026b0c3f6d1d3a4be7d80 (diff) | |
download | sqlalchemy-d917119235e7b43413e9b191492e0f5f48425cb0.tar.gz |
scalar() returns None if no rows
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r-- | lib/sqlalchemy/sql.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index c3048de29..4ec7cbb7b 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -293,7 +293,11 @@ class Compiled(ClauseVisitor): """executes this compiled object via the execute() method, then returns the first column of the first row. Useful for executing functions, sequences, rowcounts, etc.""" - return self.execute(*multiparams, **params).fetchone()[0] + row = self.execute(*multiparams, **params).fetchone() + if row is not None: + return row[0] + else: + return None class ClauseElement(object): """base class for elements of a programmatically constructed SQL expression.""" |