diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-09 15:54:10 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-09 15:54:10 +0000 |
commit | 3b724ae1ccefd0b8db516877b58a3411803e44ad (patch) | |
tree | 1677b1638802d9002dfb7ff723e42abbed100352 /lib/sqlalchemy/sql/expression.py | |
parent | 8204fa721da8c706b5030fb836d1a94696d2200a (diff) | |
download | sqlalchemy-3b724ae1ccefd0b8db516877b58a3411803e44ad.tar.gz |
- Bind params now subclass ColumnElement which allows them to be
selectable by orm.query (they already had most ColumnElement
semantics).
- Added select_from() method to exists() construct, which becomes
more and more compatible with a regular select().
- Bind parameters/literals given a True/False value will detect
their type as Boolean
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9b24f7930..f7fc5f961 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1814,7 +1814,7 @@ class FromClause(Selectable): def _populate_column_collection(self): pass -class _BindParamClause(ClauseElement, _CompareMixin): +class _BindParamClause(ColumnElement): """Represent a bind parameter. Public constructor is the ``bindparam()`` function. @@ -1874,7 +1874,7 @@ class _BindParamClause(ClauseElement, _CompareMixin): self.type = type_() else: self.type = type_ - + def _clone(self): c = ClauseElement._clone(self) if self.unique: @@ -2291,6 +2291,13 @@ class _Exists(_UnaryExpression): def _get_from_objects(self, **modifiers): return [] + def select_from(self, clause): + """return a new exists() construct with the given expression set as its FROM clause.""" + + e = self._clone() + e.element = self.element.select_from(clause).self_group() + return e + def where(self, clause): """return a new exists() construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any.""" |