diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 6 |
3 files changed, 11 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 095c84f03..85d5ff6da 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -215,7 +215,10 @@ class Compiled(object): pass def _execute_on_connection(self, connection, multiparams, params): - return connection._execute_compiled(self, multiparams, params) + if self.can_execute: + return connection._execute_compiled(self, multiparams, params) + else: + raise exc.ObjectNotExecutableError(self.statement) @property def sql_compiler(self): diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index e277b28a4..75d5368d5 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -259,7 +259,10 @@ class ClauseElement(Visitable): return self def _execute_on_connection(self, connection, multiparams, params): - return connection._execute_clauseelement(self, multiparams, params) + if self.supports_execution: + return connection._execute_clauseelement(self, multiparams, params) + else: + raise exc.ObjectNotExecutableError(self) def unique_params(self, *optionaldict, **kwargs): """Return a copy with :func:`bindparam()` elements replaced. diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index e364b2e7f..98a96fd56 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -71,9 +71,6 @@ class SchemaItem(SchemaEventTarget, visitors.Visitable): __visit_name__ = 'schema_item' - def _execute_on_connection(self, connection, multiparams, params): - return connection._execute_default(self, multiparams, params) - def _init_items(self, *args): """Initialize the list of child items for this SchemaItem.""" @@ -1941,6 +1938,9 @@ class DefaultGenerator(_NotAColumnExpr, SchemaItem): bind = _bind_or_error(self) return bind._execute_default(self, **kwargs) + def _execute_on_connection(self, connection, multiparams, params): + return connection._execute_default(self, multiparams, params) + @property def bind(self): """Return the connectable associated with this default.""" |
