On Wed, 2007-10-31 at 18:45 -0400, George Vilches wrote:
> First of all, thank you for the well thought-out response, I appreciate 
> your efforts. :)
> 
> Here is the crux of the matter, without any examples, and you phrased it 
> best:
>  > "You've overridden that by
>  > specifying a to_field whose value is not unique (allowing that may be
>  > a bug in Django)."
> 
> The whole point is that I think the behavior is a bug in Django, because 
> it's inconsistent as to which the count() is generating.  I was hoping 
> someone knew the core well enough to explain this inconsistency.  Core 
> devs, is this a bug, or do all of us who have commented on it not 
> understand why this behavior gives these apparently inconsistent values?

It's a bug. It's possible, although I haven't dug into the SQL spec in
detail to confirm this yet, that it's actually invalid SQL to have a
reference to a non-unique column like this. Certainly PostgreSQL will
raise an error if you try to do it and as far as I can understand it,
that should be the correct result. The fact that some databases don't
raise an error means it's either undefined or another case of database
vendors treating the spec as a wishlist from some committee, rather than
a requirement. The root problem is that the join relation is not
well-defined in this case when you look at it from the relational
algebra perspective.

It will be a validation error once queryset-refactor is merged into
trunk. You must put unique=True on the targets of a "to_field" relation
and you might as well start doing that now.

Regards,
Malcolm

-- 
Many are called, few volunteer. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to