#17415: django.contrib.sites.management.create_default_site populates invalid 
data
in DB
-------------------------------------+-------------------------------------
     Reporter:  niko@…               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  contrib.sites        |                  Version:  SVN
     Severity:  Release blocker      |               Resolution:
     Keywords:  site admin create    |             Triage Stage:
  db orm                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * needs_better_patch:   => 0
 * type:  Uncategorized => Bug
 * needs_tests:   => 0
 * needs_docs:   => 0


Old description:

> With a PostgeSQL backend, in trunk revision 1.4 pre-alpha SVN-17189
>
> During syncdb, in the function
> django.contrib.sites.management.create_default_site,
> the default Site 'exemple.com' is created.
> But for some reason, the postgres sequence 'django_site_id_seq' is then
> in an incorrect state.
> The last value = 1 (this is ok)
> but the flag "Will increment last value before returning next value
> (is_called)" = No
> And this parameter is different in any other table generated by the ORM.
>
> Name    Start value     Last value      Increment by    Max value
> Min value       Cache value     Log count       Can cycle?      Will
> increment last value before returning next value (is_called)?
> django_site_id_seq      1       1       1       9223372036854775807     1
> 1       1       No      No
>

> What happens then?
> If you go to the admin and want to add a second Site, when u save, you
> get the exception:
>
> Exception Type:         IntegrityError
>
> duplicate key value violates unique constraint "django_site_pkey"
> DETAIL:  Key (id)=(1) already exists.
>
> At this point, the add in the DB failed, but the ORM just changed the
> flag in the Sequence django_site_id_seq.is_called = Yes
>
> This will allow the next attempt to save this second Site (reload the
> page and resend the POST data, by exemple) to succeed.
>
> How to reproduce the bug at this stage:
> in the postgresql, delete the table django_site, run manage.py syncdb,
> this will create a new table and repopulate the exemple.com default Site,
> and the buggy is_called tag on the django_site_id_seq sequence.
>
> Then, i dont know why the function
> django.contrib.sites.management.create_default_site is putting this tag
> to False.
>
> I havent tested on mysql, andi dont know how increment index is working
> there.

New description:

 With a PostgeSQL backend, in trunk revision 1.4 pre-alpha SVN-17189

 During syncdb, in the function
 django.contrib.sites.management.create_default_site,
 the default Site 'exemple.com' is created.
 But for some reason, the postgres sequence 'django_site_id_seq' is then in
 an incorrect state.
 The last value = 1 (this is ok)
 but the flag "Will increment last value before returning next value
 (is_called)" = No
 And this parameter is different in any other table generated by the ORM.

 {{{
 Name    Start value     Last value      Increment by    Max value
 Min value       Cache value     Log count       Can cycle?      Will
 increment last value before returning next value (is_called)?
 django_site_id_seq      1       1       1       9223372036854775807     1
 1       1       No      No
 }}}

 What happens then?
 If you go to the admin and want to add a second Site, when u save, you get
 the exception:

 {{{
 Exception Type:         IntegrityError

 duplicate key value violates unique constraint "django_site_pkey"
 DETAIL:  Key (id)=(1) already exists.
 }}}

 At this point, the add in the DB failed, but the ORM just changed the flag
 in the Sequence django_site_id_seq.is_called = Yes

 This will allow the next attempt to save this second Site (reload the page
 and resend the POST data, by exemple) to succeed.

 How to reproduce the bug at this stage:
 in the postgresql, delete the table django_site, run manage.py syncdb,
 this will create a new table and repopulate the exemple.com default Site,
 and the buggy is_called tag on the django_site_id_seq sequence.

 Then, i dont know why the function
 django.contrib.sites.management.create_default_site is putting this tag to
 False.

 I havent tested on mysql, andi dont know how increment index is working
 there.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17415#comment:1>
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to