summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerebus1 <erebus@mail.ua>2016-06-05 12:56:25 +0300
committererebus1 <erebus@mail.ua>2016-06-05 12:56:25 +0300
commita39774e3f568aa964c1d99da2ff2d4654a291bf7 (patch)
tree3ceb1c177149ab37b665c5d8810676017ca5f39c
parent991346d5bbc29479c6c500c3f2b64fd6cc2e9a39 (diff)
downloadsqlalchemy-pr/283.tar.gz
Raise error on empty in_pr/283
I think it would be good idea to add error on empy in_ usage in version 1.1.* Because current implementation is not fully correct: Firstly, it's not optimised, because of sequential scan Secondly, in current implementation null in () will return null, when in sql it should return False, try this: select null in (select 1 from some_table where false); -> false but not null I understant that this can break some legacy code, but current implementation is obscure and quite expensive
-rw-r--r--lib/sqlalchemy/sql/default_comparator.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py
index 1bb1c344c..975da9d30 100644
--- a/lib/sqlalchemy/sql/default_comparator.py
+++ b/lib/sqlalchemy/sql/default_comparator.py
@@ -146,6 +146,7 @@ def _in_impl(expr, op, seq_or_selectable, negate_op, **kw):
# build the contradiction as it handles NULL values
# appropriately, i.e. "not (x IN ())" should not return NULL
# values for x.
+ assert False, 'empty in'
util.warn('The IN-predicate on "%s" was invoked with an '
'empty sequence. This results in a '