Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 24, 2010 19:36:39

Tim S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

case insensitive "in" query


I have two lists of values and I need to filter a queryset to only
rows in which a column's value is in one of these lists. The data is
not case consistent, so if I were comparing the column to a single
value I would use the "iexact" lookup type. Since I'm comparing to a
list of values I'm using the "in" lookup type, but there's no way to
make that case insensitive that I know of. The way I'm doing this is
by looping through the list I want to exclude and doing an "iexact"
lookup on each of those values. It feels like a really crappy way to
do it, but I don't know of anything better. Is there an alternative?

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 24, 2010 19:51:31

Christophe P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

case insensitive "in" query


On Dec 24, 2010, at 11:12 AM, Tim Saylor wrote:

> Is there an alternative?

This is probably a good case for doing a raw query. You can then do something
along the lines of "WHERE lower(field) IN ('', '''...)". Depending on the
data, creating a functional index on "lower(field)" might help performance.

--
-- Christophe Pettus
x...@thebuild.com

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 17th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support