#7823: ForeignKey get_db_prep_lookup doesn't work for custom primary key
---------------------------------------+------------------------------------
Reporter: isagalaev | Owner: mtredinnick
Status: new | Milestone:
Component: Database wrapper | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------+------------------------------------
Comment (by isagalaev):
Malcolm, you were talking about some better way to do this and I'd like to
shae what I was trying also.
First, to get rid of {{{isinstance(..., list)}}} I think we should change
all the get_db_prep_lookup's to return lists. Currently it's not the case
even for built-in fields (see DateField, DecimalField for example).
Then if the type returning will be uniform the inner loop would could be
changed for simpler recursion. Something like this:
{{{
def pk_trace(value):
try:
v, field = getattr(value, value._meta.pk.name)
if lookup_type in ['in', 'range']:
v = [v]
return field.get_db_prep_lookup(lookup_type, v)[0]
except AttributeError:
return value
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/7823#comment:3>
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
-~----------~----~----~----~------~----~------~--~---