On Apr 11, 6:05 pm, "Rick Morrison" <[EMAIL PROTECTED]> wrote:
> Most of the way it works is great:
>
> >> col.in_(v1, v2, v2)
>
>    COL IN (v1, v2, v3)>> col.in_(v1)
>
>    COL = v1
>
> but this one:
>
> >> col.in_()
>
>    COL IS NULL
>
> is a mapping I don't think
> is right. In our case, it caused an unexpected enormous table scan
> that loaded over 800MB of data and set our server to swapping.

I'd say this is a definite bug. The semantics of col.in_(list) should
be column value equals any of the values in the list. For an empty
list it should be a constant false, because no value exists in an
empty list, not even an missing value (null). What makes it a bit
tricky is the fact that for null values the result should actually
also be null. When straight .in_() is used it doesn't really matter,
but when the negation is used then it starts to matter. That's because
not_(col.in_()) should be the equivalent of COL IS NOT NULL. I think
the best way would be to compile it to COL != COL, it has the correct
behaviour when negated as well as not negated. Diff follows:
Index: lib/sqlalchemy/sql.py
===================================================================
--- lib/sqlalchemy/sql.py       (revision 2494)
+++ lib/sqlalchemy/sql.py       (working copy)
@@ -895,5 +895,5 @@
     def in_(self, *other):
         if len(other) == 0:
-            return self.__eq__(None)
+            return self.__ne__(self)
         elif len(other) == 1 and not hasattr(other[0],
'_selectable'):
             return self.__eq__(other[0])


Ants


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to