On Tue, Apr 5, 2011 at 10:09 PM, Matt Hoskins <skaffe...@googlemail.com> wrote:
> My apologies for reposting this - I originally posted this at the end
> of January and as soon as I posted it I realised that with the push
> for bug squashing for the 1.3 release going on I probably wouldn't get
> any attention (and thus comment or replies :), so I'm trying a repost
> now that 1.3 is out. If someone knowledgeable about the query code in
> django could comment on whether the behaviour is by design or an
> oversight that would be useful!
>
> (Below where I say "reverse name" I mean using that reverse name from
> the model that the OneToOneField relates to)
> ---------
> Working on some code I've hit that the reverse name for a
> OneToOneField cannot be used, it seems, in values_list or values. I
> couldn't see why there would need to be such an exclusion, given it is
> a one-to-one relationship, so am wondering if it's just an oversight
> in the code or a deliberate exclusion?

I'd need to go spelunking through the code to be sure, but if this is
happening, I'd be guessing it's oversight. From a quick scan of the
test suite, I can't find an obvious test for values() on one-to-one
fields.

As for the reason for this; OneToOne keys are a degenerate case of
foreign key, but in the reverse direction, they have a single value
(as opposed to the multiple values of a reverse foreign key). As a
result, the oversight would be failing to include reverse one-to-ones
in the list of valid names, overriding the default interpretation for
the ForeignKey from which they are inherited.

So - it sounds like this should be reported as a ticket; If you could
also reduce this to a test case that is integrated into Django's test
suite (regressiontests/one_to_one_regress would be a good place,
because it has o2o models ready to use), that would be very helpful.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to