#7823: ForeignKey get_db_prep_lookup doesn't work for custom primary key
---------------------------------------+------------------------------------
Reporter: isagalaev | Owner: mtredinnick
Status: new | Milestone: 1.0
Component: Database wrapper | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------+------------------------------------
Comment (by isagalaev):
> when I'll have another epiphany
Don't know if it was it but I've made a patch without ugly 'isinstance'
checks that works and passes tests. However! There are two gotchas.
1. I took liberty in calling get_db_prep_lookup on pk fields with 'exact'
lookup_type always. This means that when doing
{{{filter(parent__in=[parent1, parent2, parent3]}}} each pk value from a
list would be looked up with {{{get_db_prep_lookup('exact', v)}}} instead
of {{{get_db_prep_lookup('in', [v])}}}. I think that it's not that
important because I can't invent a real use-case where 'in' lookups would
yield essentially different results than a list of 'exact's
2. This patch actually relies on the fact that 'exact' lookups return a
list. It is now consistent throughout Django after introducing
get_db_prep_value and general implementation of lookup logic. But we may
break some user code that was returning scalar values on exact lookups.
But I actually think it's a good thing because inconsistencies are bad and
now it's better time to break it than after 1.0
Anyway, Malcolm, the choice is yours!
--
Ticket URL: <http://code.djangoproject.com/ticket/7823#comment:9>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---