Thursday, October 20, 2011

Re: .count() returning unexpected results

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" % (i, alias),)

use

self.assertEqual(
m.Person.objects.count(), #only 1
results.count(), # comes back as 6 for "William"
"Failed #%i on %r" % (i, alias),
)

This makes it clearer that there's only the one person in the DB
(no fixtures being loaded). The underlying SQL brings back the
number of rows caused by the join of Person with Alias, but it
seems a bug that .objects.filter().count() should ever return
more than .objects.count()

-tkc

--
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, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate