diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-10-23 17:41:55 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-10-23 17:44:52 -0400 |
commit | f035b6e0a41238d092ea2ddd10fdd5de298ff789 (patch) | |
tree | 76c2c9b9e4b63964847126aba054de19cfc485f7 /lib/sqlalchemy/sql/selectable.py | |
parent | 382cd56772efd92a9fe5ce46623029a04163c8cf (diff) | |
download | sqlalchemy-f035b6e0a41238d092ea2ddd10fdd5de298ff789.tar.gz |
An overhaul of expression handling for special symbols particularly
with conjunctions, e.g.
``None`` :func:`.expression.null` :func:`.expression.true`
:func:`.expression.false`, including consistency in rendering NULL
in conjunctions, "short-circuiting" of :func:`.and_` and :func:`.or_`
expressions which contain boolean constants, and rendering of
boolean constants and expressions as compared to "1" or "0" for backends
that don't feature ``true``/``false`` constants. [ticket:2804]
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 43d5a084c..550e250f1 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -14,7 +14,7 @@ from .elements import ClauseElement, TextClause, ClauseList, \ from .elements import _clone, \ _literal_as_text, _interpret_as_column_or_from, _expand_cloned,\ _select_iterables, _anonymous_label, _clause_element_as_expr,\ - _cloned_intersection, _cloned_difference + _cloned_intersection, _cloned_difference, True_ from .base import Immutable, Executable, _generative, \ ColumnCollection, ColumnSet, _from_objects, Generative from . import type_api @@ -2519,13 +2519,9 @@ class Select(HasPrefixes, SelectBase): :term:`method chaining`. """ - self._reset_exported() - whereclause = _literal_as_text(whereclause) - if self._whereclause is not None: - self._whereclause = and_(self._whereclause, whereclause) - else: - self._whereclause = whereclause + self._reset_exported() + self._whereclause = and_(True_._ifnone(self._whereclause), whereclause) def append_having(self, having): """append the given expression to this select() construct's HAVING @@ -2538,10 +2534,8 @@ class Select(HasPrefixes, SelectBase): :term:`method chaining`. """ - if self._having is not None: - self._having = and_(self._having, _literal_as_text(having)) - else: - self._having = _literal_as_text(having) + self._reset_exported() + self._having = and_(True_._ifnone(self._having), having) def append_from(self, fromclause): """append the given FromClause expression to this select() construct's |