diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2017-03-14 19:39:37 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@awstats.zzzcomputing.com> | 2017-03-14 19:39:37 -0400 |
| commit | 0a35ccc6bd1acaa91f32c8e0140000b19ae85e14 (patch) | |
| tree | 55ef032cad4685ff8645e349fd5709524a57ce36 /lib/sqlalchemy/sql/operators.py | |
| parent | 18b2dea9a48ad282a7af32633b913b5855e6f100 (diff) | |
| parent | f3b6f4f8da5223fae0a1dd948d4266b2e49e317c (diff) | |
| download | sqlalchemy-0a35ccc6bd1acaa91f32c8e0140000b19ae85e14.tar.gz | |
Merge "Add "empty in" strategies; default to "static""
Diffstat (limited to 'lib/sqlalchemy/sql/operators.py')
| -rw-r--r-- | lib/sqlalchemy/sql/operators.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index 1690d546b..01bee62cf 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -458,6 +458,17 @@ class ColumnOperators(Operators): "other" may be a tuple/list of column expressions, or a :func:`~.expression.select` construct. + In the case that ``other`` is an empty sequence, the compiler + produces an "empty in" expression. This defaults to the + expression "1 != 1" to produce false in all cases. The + :paramref:`.create_engine.empty_in_strategy` may be used to + alter this behavior. + + .. versionchanged:: 1.2 The :meth:`.ColumnOperators.in_` and + :meth:`.ColumnOperators.notin_` operators + now produce a "static" expression for an empty IN sequence + by default. + """ return self.operate(in_op, other) @@ -467,7 +478,16 @@ class ColumnOperators(Operators): This is equivalent to using negation with :meth:`.ColumnOperators.in_`, i.e. ``~x.in_(y)``. - .. versionadded:: 0.8 + In the case that ``other`` is an empty sequence, the compiler + produces an "empty not in" expression. This defaults to the + expression "1 = 1" to produce true in all cases. The + :paramref:`.create_engine.empty_in_strategy` may be used to + alter this behavior. + + .. versionchanged:: 1.2 The :meth:`.ColumnOperators.in_` and + :meth:`.ColumnOperators.notin_` operators + now produce a "static" expression for an empty IN sequence + by default. .. seealso:: @@ -957,6 +977,14 @@ def comma_op(a, b): raise NotImplementedError() +def empty_in_op(a, b): + raise NotImplementedError() + + +def empty_notin_op(a, b): + raise NotImplementedError() + + def concat_op(a, b): return a.concat(b) @@ -1073,6 +1101,8 @@ _PRECEDENCE = { ne: 5, is_distinct_from: 5, isnot_distinct_from: 5, + empty_in_op: 5, + empty_notin_op: 5, gt: 5, lt: 5, ge: 5, |
