#6947: Auto increment field in sqlite
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  ctrochalakis                       |         Status:  closed
                   Type:             |      Component:  Database layer
  Uncategorized                      |  (models, ORM)
              Milestone:             |       Severity:  Normal
                Version:  SVN        |       Keywords:  sqlite
             Resolution:  invalid    |      Has patch:  0
           Triage Stage:             |    Needs tests:  0
  Unreviewed                         |  Easy pickings:  0
    Needs documentation:  0          |
Patch needs improvement:  0          |
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
Changes (by django.bigfudge@…):

 * ui_ux:   => 0
 * type:   => Uncategorized
 * severity:   => Normal
 * easy:   => 0


Comment:

 I'm not reopening this ticket myself, but I would like to petition for it
 to be reopened because of a specific problem with django_reversion, and
 likely other code intended to version django objects.

 Quite reasonably, reversion versions are not deleted when an original
 object is deleted. However, versions do use the deleted objects' id to
 link back to that object. If using sqlite, when an object is deleted then
 it's pk is freed up for reuse. When this happens, reversion_versions link
 back to the wrong object, and in the admin it looks like there are more
 versions than there actually are ( you get the full history for any object
 which has had the pk in question).

 Were Sebastian right that AUTOINCREMENT would only add new rows with
 largest pk+1 then this would still be a problem: the object with the
 largest PK could be deleted, and a new one would reuse this pk, and this
 would still confuse reversion. However, quoting from the SQLITE docs:

 "The behavior implemented by the AUTOINCREMENT keyword is subtly different
 from the default behavior. With AUTOINCREMENT, rows with automatically
 selected ROWIDs are guaranteed to have ROWIDs that have never been used
 before by the same table in the same database."
 http://www.sqlite.org/autoinc.html

 So, if the AUTOINCREMENT keyword were added by django when creating tables
 then this would prevent reversion getting confused. I'll cross post this
 to the reversion people, but it seems to me that fixing django would be a
 lot easier than trying to make the reversion app compatible with sqlite.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/6947#comment:3>
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 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