#29913: Issue with ForeignKey to model with non-abstract base class and UUID-pk
-------------------------------------+-------------------------------------
Reporter: theKomix | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have this models:
{{{
class Vehicle(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
created_date = models.DateTimeField(verbose_name="Created date",
auto_now_add=True)
class Car(Vehicle):
Name = models.CharField("Name", max_length=255)
class Item(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
car = models.ForeignKey(
Car, related_name="items", on_delete=models.PROTECT)
}}}
I develop with SQLite db which doesn't support UUID columns.
When I query Items I get item with car_id - hex value. I debuged
application and found that in {{{DatabaseOperations.get_db_converters()}}}
{{{internal_type}}} for column car is OneToOneField and it didn't have
{{{self.convert_uuidfield_value}}} of course.
This issue is reason of exception in function {{{prefetch_related}}}:
{{{
Exception Type: KeyError
Exception Value:
('27156424-a53d-4b4e-a909-04ceba6c65e1',)
Exception Location: C:\Source\InMeta.py\inmeta\venv\lib\site-
packages\django\db\models\fields\related_descriptors.py in
get_prefetch_queryset, line 611
}}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29913>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.0adb1bab7b891e0be9849316d2cb80aa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.