object might be label'ed as something else which does contain mixed case, and
propigating "case_sensitive=False" breaks that. Other fixes to quoting
when using labels and "fake" column objects
+ - added a "supports_execution()" method to ClauseElement, so that individual
+ kinds of clauses can express if they are appropriate for executing...such as,
+ you can execute a "select", but not a "Table" or a "Join".
- orm:
- further rework of the recent polymorphic relationship refactorings, as well
as the mechanics of relationships overall. Allows more accurate ORM behavior
return self.execute_compiled(elem.compile(engine=self.__engine, parameters=param), *multiparams, **params)
def execute_compiled(self, compiled, *multiparams, **params):
"""executes a sql.Compiled object."""
+ if not compiled.can_execute:
+ raise exceptions.ArgumentError("Not an executeable clause: %s" % (str(compiled)))
cursor = self.__engine.dialect.create_cursor(self.connection)
parameters = [compiled.get_params(**m) for m in self._params_to_listofdicts(*multiparams, **params)]
if len(parameters) == 1:
self.statement = statement
self.parameters = parameters
self.engine = engine
-
+ self.can_execute = statement.supports_execution()
+
def compile(self):
self.statement.accept_visitor(self)
self.after_compile()
"""accept a ClauseVisitor and call the appropriate visit_xxx method."""
raise NotImplementedError(repr(self))
+ def supports_execution(self):
+ """return True if this clause element represents a complete executable statement"""
+ return False
+
def copy_container(self):
"""return a copy of this ClauseElement, iff this ClauseElement contains other ClauseElements.
visitor.visit_textclause(self)
def _get_from_objects(self):
return []
-
+ def supports_execution(self):
+ return True
+
class _Null(ColumnElement):
"""represents the NULL keyword in a SQL statement. public contstructor is the
null() function."""
alias = alias + "_" + hex(random.randint(0, 65535))[2:]
self.name = alias
self.case_sensitive = getattr(baseselectable, "case_sensitive", alias.lower() != alias)
-
+ def supports_execution(self):
+ return self.original.supports_execution()
def _locate_oid_column(self):
if self.selectable.oid_column is not None:
return self.selectable.oid_column._make_proxy(self)
class _SelectBaseMixin(object):
"""base class for Select and CompoundSelects"""
+ def supports_execution(self):
+ return True
def order_by(self, *clauses):
if len(clauses) == 1 and clauses[0] is None:
self.order_by_clause = ClauseList()
class _UpdateBase(ClauseElement):
"""forms the base for INSERT, UPDATE, and DELETE statements."""
+ def supports_execution(self):
+ return True
def _process_colparams(self, parameters):
"""receives the "values" of an INSERT or UPDATE statement and constructs
appropriate bind parameters."""