orderby = self.strings[orderby]
class SelectVisitor(sql.ClauseVisitor):
def visit_select(self, select):
- select.append_column(sql.column("ROW_NUMBER() OVER (ORDER BY %s)" % orderby).label("ora_rn"))
+ select.append_column(sql.literal_column("ROW_NUMBER() OVER (ORDER BY %s)" % orderby).label("ora_rn"))
select.accept_visitor(SelectVisitor())
limitselect = sql.select([c for c in select.c if c.key!='ora_rn'])
if select.offset is not None:
orderby = select.oid_column
orderby.accept_visitor(self)
orderby = self.strings[orderby]
- select.append_column(sql.column("ROW_NUMBER() OVER (ORDER BY %s)" % orderby).label("ora_rn"))
+ select.append_column(sql.literal_column("ROW_NUMBER() OVER (ORDER BY %s)" % orderby).label("ora_rn"))
limitselect = sql.select([c for c in select.c if c.key!='ora_rn'])
if select.offset is not None:
limitselect.append_whereclause("ora_rn>%d" % select.offset)
quote_schema=False : indicates that the Namespace identifier must be properly escaped and quoted before being sent
to the database. This flag overrides all other quoting behavior.
- case_sensitive=True : indicates quoting should be used if the identifier needs it.
+ case_sensitive=True : indicates quoting should be used if the identifier contains mixed case.
- case_sensitive_schema=True : indicates quoting should be used if the identifier needs it.
+ case_sensitive_schema=True : indicates quoting should be used if the identifier contains mixed case.
"""
super(Table, self).__init__(name)
self._metadata = metadata
to the database. This flag should normally not be required as dialects can auto-detect conditions where quoting
is required.
- case_sensitive=True : indicates quoting should be used if the identifier needs it.
+ case_sensitive=True : indicates quoting should be used if the identifier contains mixed case.
"""
name = str(name) # in case of incoming unicode
super(Column, self).__init__(name, None, type)
import string, re, random, sets
-__all__ = ['text', 'table', 'column', 'func', 'select', 'update', 'insert', 'delete', 'join', 'and_', 'or_', 'not_', 'between_', 'case', 'cast', 'union', 'union_all', 'except_', 'except_all', 'intersect', 'intersect_all', 'null', 'desc', 'asc', 'outerjoin', 'alias', 'subquery', 'literal', 'bindparam', 'exists', 'extract','AbstractDialect', 'ClauseParameters', 'ClauseVisitor', 'Executor', 'Compiled', 'ClauseElement', 'ColumnElement', 'ColumnCollection', 'FromClause', 'TableClause', 'Select', 'Alias', 'CompoundSelect','Join', 'Selectable']
+__all__ = ['text', 'table', 'column', 'literal_column', 'func', 'select', 'update', 'insert', 'delete', 'join', 'and_', 'or_', 'not_', 'between_', 'case', 'cast', 'union', 'union_all', 'except_', 'except_all', 'intersect', 'intersect_all', 'null', 'desc', 'asc', 'outerjoin', 'alias', 'subquery', 'literal', 'bindparam', 'exists', 'extract','AbstractDialect', 'ClauseParameters', 'ClauseVisitor', 'Executor', 'Compiled', 'ClauseElement', 'ColumnElement', 'ColumnCollection', 'FromClause', 'TableClause', 'Select', 'Alias', 'CompoundSelect','Join', 'Selectable']
def desc(column):
"""return a descending ORDER BY clause element, e.g.:
return _Label(name, obj)
def column(text, table=None, type=None, **kwargs):
- """returns a textual column clause, relative to a table. this is also the primitive version of
+ """return a textual column clause, relative to a table. this is also the primitive version of
a schema.Column which is a subclass. """
return _ColumnClause(text, table, type, **kwargs)
+def literal_column(text, table=None, type=None, **kwargs):
+ """return a textual column clause with the 'literal' flag set. this column will not be quoted"""
+ return _ColumnClause(text, table, type, is_literal=True, **kwargs)
+
def table(name, *columns):
"""returns a table clause. this is a primitive version of the schema.Table object, which is a subclass
of this object."""
class _ColumnClause(ColumnElement):
"""represents a textual column clause in a SQL statement. May or may not
be bound to an underlying Selectable."""
- def __init__(self, text, selectable=None, type=None, _is_oid=False, case_sensitive=True):
+ def __init__(self, text, selectable=None, type=None, _is_oid=False, case_sensitive=True, is_literal=False):
self.key = self.name = text
self.table = selectable
self.type = sqltypes.to_instance(type)
self._is_oid = _is_oid
self.__label = None
- self.case_sensitive = False #text.isalpha() and not text.islower()
+ self.case_sensitive = case_sensitive
+ self.is_literal = is_literal
def _get_label(self):
if self.__label is None:
if self.table is not None and self.table.named_with_column():
def append_column(self, column):
if _is_literal(column):
- column = _ColumnClause(str(column), self)
+ column = literal_column(str(column), table=self)
self._raw_columns.append(column)