summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-06 00:59:09 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-06 00:59:09 +0000
commitb73b14f070864684bc9a775b481257756ff02055 (patch)
tree6c81ccc8212cf25a8759bd9fd4a79e4837beacba /lib/sqlalchemy/sql.py
parent98230f7c32ff0821984afc1aa4b736fa594c390d (diff)
downloadsqlalchemy-b73b14f070864684bc9a775b481257756ff02055.tar.gz
- draft sqlexpression tutorial
- added some generative methods to exists() - got clause adapter to work with join()
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index a6db06423..022e05ca1 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -1682,7 +1682,7 @@ class FromClause(Selectable):
def alias(self, name=None):
return Alias(self, name)
-
+
def named_with_column(self):
"""True if the name of this FromClause may be prepended to a
column in a generated SQL statement.
@@ -1714,7 +1714,13 @@ class FromClause(Selectable):
An example would be an Alias of a Table is derived from that Table."""
return False
-
+
+ def replace_selectable(self, old, alias):
+ """replace all occurences of FromClause 'old' with the given Alias object"""
+
+ from sqlalchemy import sql_util
+ return sql_util.ClauseAdapter(alias).traverse(self, clone=True)
+
def corresponding_column(self, column, raiseerr=True, keys_ok=False, require_embedded=False):
"""Given a ``ColumnElement``, return the exported
``ColumnElement`` object from this ``Selectable`` which
@@ -2274,6 +2280,16 @@ class _Exists(_UnaryExpression):
s = select(*args, **kwargs).self_group()
_UnaryExpression.__init__(self, s, operator=Operators.exists)
+ def correlate(self, fromclause):
+ e = self._clone()
+ e.element = self.element.correlate(fromclause).self_group()
+ return e
+
+ def where(self, clause):
+ e = self._clone()
+ e.element = self.element.where(clause).self_group()
+ return e
+
def _hide_froms(self, **modifiers):
return self._get_from_objects(**modifiers)
@@ -2819,6 +2835,11 @@ class _SelectBaseMixin(object):
def as_scalar(self):
return _ScalarSelect(self)
+ def apply_labels(self):
+ s = self._generate()
+ s.use_labels = True
+ return s
+
def label(self, name):
return self.as_scalar().label(name)