First off, let's be clear: Django isn't throwing away results or
anything like. The database simply isn't returning them. So we need to
work out why that is happening.
One thing that immediately jumps out is that the "name" column is "Sea",
not "sea" (different capitalisation). Have you configured your database
to be case-sensitive in comparisons (and perhaps the MySQL shell is
case-insensitive or something?). Rule that in or out as a start.
A second step would be to start simplifying the query to work out how
simple it has to be before it starts working. For example, remove the
dynamically generated "in" list and replace it with a hard-coded string
(e.g. "sea"). That shouldn't change anything, but it removes one layer
of complexity and is the first step of many towards creating the
simplest possible example. Test that out and see if it still fails.
What happens when you evaluate that queryset from the "manage.py shell"
prompt? That is, import the Tag model and type in the
Tag.objects.filter(...) line and see what happens. If you don't see the
same result as when the code is executed in the program, you now have a
difference to work with. Again, that's trying to simplify things as much
as possible -- we're now down to just the line in question.
If that still doesn't generate any results, see if the most basic
queryset Tag.objects.all() returns something. Then make a much simple
filter -- such as Tag.objects.filter(id=28), which should return the row
you indicate. Then try Tag.objects.filter(name="sea") and
Tag.objects.filter(name="Sea").
Hopefully you can see where this is going: start from something that
doesn't work and remove bits. Start from something that works and add
bits. Eventually you'll meet in the middle and we'll have a better idea
of what the critical piece is.
Regards,
Malcolm
>
>
> On Mon, Jan 5, 2009 at 3:37 PM, JonUK <jdoull <at> flinttechnology.co.uk>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
"Django users" group. To post to this group, send email to django-users <at>
googlegroups.com To unsubscribe from this group, send email to django-
users+unsubscribe <at> googlegroups.com For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
Apologies for the long silence before responding. Although I do not recall if
this was the precisely the issue (it was a long time ago), I did eventually hunt
down an accepted bug in Mysql that makes the "in" clause unreliable,
particularly when used in subqueries. The recommended workaround was to replace
with joins, however my preferred solution was to use Postgres, which solved this
problem and worked a treat. I appreciated your responses - so thank you.