On Thu, Oct 20, 2011 at 12:40 PM, Tim Chase
wrote:
> On 10/19/11 20:35, Tim Chase wrote:
>
> Perhaps I should have changed the test to be more clear, instead of using
>
>> results = m.Person.objects.filter(
>> Q(name__iexact=alias) |
>> Q(aliases__alias__iexact=alias)
>> )
>>
On 10/19/11 20:35, Tim Chase wrote:
Perhaps I should have changed the test to be more clear, instead
of using
results = m.Person.objects.filter(
Q(name__iexact=alias) |
Q(aliases__alias__iexact=alias)
)
self.assertEqual(1, results.count(),
"Failed #%i on %r"
Try using DDT to see the the query being fired and walk your way up.
-V
http://about.me/venkasub
--
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@googlegroups.com.
To unsubscribe from this group,
On Wed, Oct 19, 2011 at 8:35 PM, Tim Chase
wrote:
> I understand what it's doing at a SQL level, but not sure if this is a
> "correct" behavior for .count() or the resulting list of objects.
>
> Any thoughts/suggestions?
usually adding .distinct() to the queryset makes it less surprising
--
Jav
Querying for .count() on a result (len(results) will also trigger
the issue) that pulls in a FK table throws off the count. Sample
code, tests and results below:
foo/models.py
=
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=42)
5 matches
Mail list logo