isnull lookup's contradicting result

2007-09-06 Thread omat
Hi, For Question & Answer models: Question.objects.filter(answer__isnull=False) returns the set of questions that has at least one answer, but: Question.objects.filter(answer__isnull=True) does not return the questions that has no answer. Am I missing something? Thanks, oMat --~--~--

Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee
On 9/6/07, omat <[EMAIL PROTECTED]> wrote: > > Hi, > > For Question & Answer models: > > Question.objects.filter(answer__isnull=False) > > returns the set of questions that has at least one answer, but: > > Question.objects.filter(answer__isnull=True) > > does not return the questions that has no

Re: isnull lookup's contradicting result

2007-09-06 Thread Malcolm Tredinnick
On Thu, 2007-09-06 at 20:59 +0800, Russell Keith-Magee wrote: > On 9/6/07, omat <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > For Question & Answer models: > > > > Question.objects.filter(answer__isnull=False) > > > > returns the set of questions that has at least one answer, but: > > > > Questio

Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee
On 9/6/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > When you run Question.objects.filter(answer__isnull=True), this gets > > turned into an SQL query something like: > > > > SELECT Question.* from Question INNER JOIN Answer WHERE Question.id = > > Answer.question_id WHERE Answer.id IS N

Re: isnull lookup's contradicting result

2007-09-06 Thread omat
Thanks for clarifying this with such a detailed explanation. I took the first way you have suggested and get things working with the following manager: class QuestionManager(models.Manager): def get_not_answered(self): cursor = connection.cursor() cursor.execute("""SELECT que

Re: isnull lookup's contradicting result

2007-09-06 Thread omat
Malcolm, these are the models: class Question(models.Model): question = models.CharField(max_length=150) slug = models.SlugField(max_length=150, editable=False) verb = models.ForeignKey(Verb) added = models.DateTimeField(editable=False) user = model

Re: isnull lookup's contradicting result

2007-09-06 Thread omat
When I checked the queries generated, it appears that the isnull lookups result in INNER JOINs for my case. On 6 Eylül, 16:38, omat <[EMAIL PROTECTED]> wrote: > Malcolm, these are the models: > > class Question(models.Model): > question = models.CharField(max_length=150) > slug = models

Re: isnull lookup's contradicting result

2007-09-06 Thread Malcolm Tredinnick
On Thu, 2007-09-06 at 21:25 +0800, Russell Keith-Magee wrote: > On 9/6/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > > > When you run Question.objects.filter(answer__isnull=True), this gets > > > turned into an SQL query something like: > > > > > > SELECT Question.* from Question INNER J

Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej
Hi Malcolm, On Fri, Sep 07, Malcolm Tredinnick wrote: > My bad; you're right. Only m2m does outer joins on trunk at the > moment.:( > > I've been looking at the new stuff too much lately. This problem is > fixed there, so if people can wait until that lands very shortly it will > go away. this

Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee
On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > > I'd *love* to have a sneak preview of your changes, any way? ;-) Hey! Get to the back of the line! No queue-jumping! I was here first! :-) Yours Russ Magee %-) --~--~-~--~~~---~--~~ You received this messa

Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej
On Thu, Sep 06, Russell Keith-Magee wrote: > > On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > > > > I'd *love* to have a sneak preview of your changes, any way? ;-) > > Hey! Get to the back of the line! No queue-jumping! I was here first! :-) ... checking Malcolm's Amazone wishlist ..

Re: isnull lookup's contradicting result

2007-09-06 Thread Nis Jørgensen
Michael Radziej skrev: > On Thu, Sep 06, Russell Keith-Magee wrote: > > >> On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote: >> >>> I'd *love* to have a sneak preview of your changes, any way? ;-) >>> >> Hey! Get to the back of the line! No queue-jumping! I was here first! :-) >

Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej
On Thu, Sep 06, Nis Jørgensen wrote: > > Michael Radziej skrev: > > On Thu, Sep 06, Russell Keith-Magee wrote: > > > > > >> On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote: > >> > >>> I'd *love* to have a sneak preview of your changes, any way? ;-) > >>> > >> Hey! Get to the