#36358: Tables with composite primary keys including integer columns improperly 
get
introspected as AutoField on SQLite
-------------------------------------+-------------------------------------
               Reporter:  Simon      |          Owner:  Simon Charette
  Charette                           |
                   Type:  Bug        |         Status:  assigned
              Component:  Database   |        Version:  5.2
  layer (models, ORM)                |
               Severity:  Release    |       Keywords:
  blocker                            |
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Given a models defined like

 {{{#!python
 class CompositePk(models.Model):
     pk = models.CompositePrimaryKey("field1", "field2")
     field1 = models.IntegerField()
     field2 = models.IntegerField()
 }}}

 it incorrectly gets introspected as

 {{{#!python
 class CompositePk(models.Model):
     pk = models.CompositePrimaryKey("field1", "field2")
     field1 = models.AutoField()
     field2 = models.IntegerField()
 }}}

 on SQLite which was missed by #36052
 (a8e4fd11efc65832e7d9f5582d3868c5c8bd8d88) when support for composite
 primary introspection was added even if the pre-existing test encoded this
 qwirk.

 This is likely due to the fact that [https://www.sqlite.org/autoinc.html
 SQLite surprisingly treats any integer field primary key as auto-
 incrementing] even if not explicitly specified

 > In SQLite, a column with type `INTEGER PRIMARY KEY` is an alias for the
 `ROWID` (except in `WITHOUT ROWID` tables) which is always a 64-bit signed
 integer.

 which was known when `AutoField` introspection was added in #23748
 (a35d2a4510d5beec398b1007aaa26492d6aedf97) see ticket:23748#comment:11 but
 the override of `get_field_type` was not properly adjusted when composite
 primary key introspection was added in #32234.

 Marking as a release blocker as it's a bug in a newly released feature.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36358>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701967f9b04d0-447be5cf-f1c6-4b06-b6e2-4d9babf87302-000000%40eu-central-1.amazonses.com.

Reply via email to