]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The :meth:`.Operators.notin_` operator added in 0.8 now properly
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Aug 2013 18:28:45 +0000 (13:28 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Aug 2013 18:28:45 +0000 (13:28 -0500)
produces the negation of the expression "IN" returns
when used against an empty collection.  Also in 0.8.3.

doc/build/changelog/changelog_08.rst
doc/build/changelog/changelog_09.rst
lib/sqlalchemy/sql/expression.py
test/sql/test_operators.py

index 451127fbb9db81b20c5fef6509f5f30c6bc291b7..909cda47625116469dc60773ef732cf236f46177 100644 (file)
@@ -6,6 +6,13 @@
 .. changelog::
     :version: 0.8.3
 
+    .. change::
+        :tags: bug, sql
+
+        The :meth:`.Operators.notin_` operator added in 0.8 now properly
+        produces the negation of the expression "IN" returns
+        when used against an empty collection.
+
     .. change::
         :tags: mysql, bug
         :tickets: 2791
index 03e2ba51563a508a52692f2546cca23de2284236..d9788aed22ad6eabccd5331e21ebe329dbc469c0 100644 (file)
@@ -6,6 +6,13 @@
 .. changelog::
     :version: 0.9.0
 
+    .. change::
+        :tags: bug, sql
+
+        The :meth:`.Operators.notin_` operator added in 0.8 now properly
+        produces the negation of the expression "IN" returns
+        when used against an empty collection.  Also in 0.8.3.
+
     .. change::
         :tags: orm, feature, orm
 
index b00a7399ae275355759548eb9b4fab54df302bea..121583cf832120e971fac40ba4f95aeca0156ffd 100644 (file)
@@ -2132,7 +2132,10 @@ class _DefaultColumnComparator(operators.ColumnOperators):
                       'contradiction, which nonetheless can be '
                       'expensive to evaluate.  Consider alternative '
                       'strategies for improved performance.' % expr)
-            return expr != expr
+            if op is operators.in_op:
+                return expr != expr
+            else:
+                return expr == expr
 
         return self._boolean_compare(expr, op,
                               ClauseList(*args).self_group(against=op),
index b3919d0dab089fff7e85b7422b55722f2910be0c..ce91c5b5e35759777fc8dae874e36f6102647768 100644 (file)
@@ -768,6 +768,17 @@ class InTest(fixtures.TestBase, testing.AssertsCompiledSQL):
             "mytable.myid IN (NULL)"
         )
 
+    @testing.emits_warning('.*empty sequence.*')
+    def test_in_29(self):
+        self.assert_compile(self.table1.c.myid.notin_([]),
+        "mytable.myid = mytable.myid")
+
+    @testing.emits_warning('.*empty sequence.*')
+    def test_in_30(self):
+        self.assert_compile(~self.table1.c.myid.in_([]),
+        "mytable.myid = mytable.myid")
+
+
 class MathOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL):
     __dialect__ = 'default'