The iexact lookup shouldn't even be defined for number types should it? I'm 
assuming it is due to backwards compatibility (from 1.7 when custom lookups 
landed), but what would that even mean? If we're not able to remove iexact 
lookup from number types then I would agree that it should also throw an 
error, because there's no reason I can see to ever iexact compare a number 
to an empty string unless there's a problem in the calling code.

On Saturday, 13 February 2016 10:58:11 UTC+11, belorn mandos wrote:
>
> When working with QuerySets and IntegerFields, I saw that comparison to
> a string with no digits in it throws a ValueError exception when I did
>
> ...objects.filter(org_number = criteria)
>
> or
>
> ...objects.filter(org_number__exact = criteria)
>
> However, when using iexact, it did not throw an exception, so
>
> ...objects.filter(org_number__iexact = criteria)
>
> worked fine. Of course, a case-insensitive function should not be used
> for the purpose of avoiding a casting issue so I initially assumed that
> this must be an odd implementation detail that one can't rely on. Python
> however does permit int and string comparison (1 == "foo") without it
> throwing a ValueError, so which of the two behaviors is doing the right
> thing here? Is "__exact" being too strict with its input, or is __iexact
> too relaxed?
>
> The question is not purely philosophic, since ignoring type casting
> makes my current code a simple and short Q query with
> multiple OR arguments in it.
>
> /Björn Påhlsson
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/0eec9e54-0e5b-46a5-91e7-380f1ca4afe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to