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/default_comparator.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/default_comparator.py')
| -rw-r--r-- | lib/sqlalchemy/sql/default_comparator.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py index 7498bbe5d..d409ebacc 100644 --- a/lib/sqlalchemy/sql/default_comparator.py +++ b/lib/sqlalchemy/sql/default_comparator.py @@ -146,23 +146,14 @@ def _in_impl(expr, op, seq_or_selectable, negate_op, **kw): else: o = expr._bind_param(op, o) args.append(o) - if len(args) == 0: - # Special case handling for empty IN's, behave like - # comparison against zero row selectable. We use != to - # build the contradiction as it handles NULL values - # appropriately, i.e. "not (x IN ())" should not return NULL - # values for x. - - util.warn('The IN-predicate on "%s" was invoked with an ' - 'empty sequence. This results in a ' - 'contradiction, which nonetheless can be ' - 'expensive to evaluate. Consider alternative ' - 'strategies for improved performance.' % expr) - if op is operators.in_op: - return expr != expr - else: - return expr == expr + if len(args) == 0: + op, negate_op = ( + operators.empty_in_op, + operators.empty_notin_op) if op is operators.in_op \ + else ( + operators.empty_notin_op, + operators.empty_in_op) return _boolean_compare(expr, op, ClauseList(*args).self_group(against=op), |
