summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/exc.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-08-31 14:34:54 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-08-31 17:04:35 -0400
commitc7b9c84312b6b252e68ea704670d0ea7fc0042f0 (patch)
treea71b8cbbb123e10a779c3a1f8efb4fc09ce47bf1 /lib/sqlalchemy/exc.py
parent53c3119ebb6801cbfcaf2841311d117eba250444 (diff)
downloadsqlalchemy-c7b9c84312b6b252e68ea704670d0ea7fc0042f0.tar.gz
Check for supports_execution at ClauseElement base
Raise a more descriptive exception / message when ClauseElement or non-SQLAlchemy objects that are not "executable" are erroneously passed to ``.execute()``; a new exception ObjectNotExecutableError is raised consistently in all cases. Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4 Fixes: #3786
Diffstat (limited to 'lib/sqlalchemy/exc.py')
-rw-r--r--lib/sqlalchemy/exc.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py
index 272984229..2a7f84de3 100644
--- a/lib/sqlalchemy/exc.py
+++ b/lib/sqlalchemy/exc.py
@@ -26,6 +26,20 @@ class ArgumentError(SQLAlchemyError):
"""
+class ObjectNotExecutableError(ArgumentError):
+ """Raised when an object is passed to .execute() that can't be
+ executed as SQL.
+
+ .. versionadded:: 1.1
+
+ """
+
+ def __init__(self, target):
+ super(ObjectNotExecutableError, self).__init__(
+ "Not an executable object: %r" % target
+ )
+
+
class NoSuchModuleError(ArgumentError):
"""Raised when a dynamically-loaded module (usually a database dialect)
of a particular name cannot be located."""