#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        
 Keywords:                    |       Stage:  Unreviewed 
Has_patch:  0                 |  
------------------------------+---------------------------------------------
 If a parent model has a user-defined field as a primary key:

 {{{
 class Parent(models.Model):
     user_id = CutomUserField(primary_key=True)

 class Child(models.Model):
     parent = models.ForeignKey(Parent)
 }}}

 then this query will fail:

 {{{
 p = Parent(...)
 Child.objects.filter(parent=p)
 }}}

 This happens because get_db_prep_lookup doesn't get called on p.user_id
 and its value (which is a custom user class) gets passed as an sql
 parameter into db.

 Patch follows.

 P.S. A bug is very practical: we have custom non-model user objects
 instead of contrib.auth.models.User and can't reference them from models
 with custom UserField because many queries using those models would break.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7823>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to