summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-01-31 19:48:13 +0000
committerJason Kirtland <jek@discorporate.us>2008-01-31 19:48:13 +0000
commit3aed5fa544685a41c0486b39dfaeb98ac69be4af (patch)
tree38ddcf38cea3e47d4e8384cf88ca6a95ee6cb78f /lib/sqlalchemy/sql/expression.py
parente1aa7573f210f76e2ddf8e45fc18007e11e5bbef (diff)
downloadsqlalchemy-3aed5fa544685a41c0486b39dfaeb98ac69be4af.tar.gz
- Friendlier exception messages for unbound, implicit execution
- Implicit binding failures now raise UnboundExecutionError
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 2e5797b34..ee867a2f9 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1002,7 +1002,13 @@ class ClauseElement(object):
e = self.bind
if e is None:
- raise exceptions.InvalidRequestError("This Compiled object is not bound to any Engine or Connection.")
+ label = getattr(self, 'description', self.__class__.__name__)
+ msg = ('This %s is not bound to an Engine or Connection. '
+ 'Execution can not proceed without a database to execute '
+ 'against. Either execute with an explicit connection or '
+ 'bind the MetaData of the underlying tables to enable '
+ 'implicit execution.') % label
+ raise exceptions.UnboundExecutionError(msg)
return e.execute_clauseelement(self, multiparams, params)
def scalar(self, *multiparams, **params):