Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#15633 closed Bug (fixed)

Bad documentation of post_syncdb signal

Reported by: Vlastimil Zíma Owned by: Justin Lilly
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Signal post_sycndb is badly documented:

  • documentation says that created_models is list, but emit_post_sync_signal is called with set when it is called from syncdb command. Surprisingly it is called with set from flush command, so there is probably error in code as well.
  • documentation suggests that post_syncdb signal is called only when table is created, so it looks like you can use it to change database structure (create contraints, triggers, ...) These SQL fail when yout post_sycndb handler is called from flush, because flush does not change database structure (except SQLs with 'IF NOT EXISTS'-like conditions). Documentation should noted that handlers of this signal should not change database structure and for such cases customize sql hack in syncdb should be used.

Change History (13)

comment:1 by Vlastimil Zíma, 14 years ago

Bug in description: flush command calls emit_post_sync_signal with list of models as in documentation

comment:2 by Luke Plant, 14 years ago

Type: Bug

comment:3 by Luke Plant, 14 years ago

Severity: Normal

comment:4 by Gabriel Hurley, 14 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Ramiro Morales, 13 years ago

Easy pickings: unset
UI/UX: unset

Seems to be a duplicate of #5848 -- but this ticket was opened on Mach 17 2011 against trunk and the other ticket was fixed on Sep 12 2010.

in reply to:  5 comment:6 by Vlastimil Zíma, 13 years ago

Replying to ramiro:

Seems to be a duplicate of #5848 -- but this ticket was opened on Mach 17 2011 against trunk and the other ticket was fixed on Sep 12 2010.

I probably missed that, but the second point is still valid.

comment:7 by Aymeric Augustin, 13 years ago

Regarding your second point, there's already a solution for this problem, see https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data

in reply to:  7 comment:8 by Vlastimil Zíma, 13 years ago

Replying to aaugustin:

Regarding your second point, there's already a solution for this problem, see https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data

This does not work one would expected from documentation.

If I create initial SQL like

ALTER TABLE "some_table"
    ADD CONSTRAINT "some_table_constraint1" CHECK (some_column = 45);

This will make flush command fail, as it emits post_syncdb signal marking that table is created (but it is not). This can be sometimes prevented using IF NOT EXISTS condition, but not always.

comment:9 by Justin Lilly, 13 years ago

Owner: changed from nobody to Justin Lilly
Status: newassigned

comment:10 by anonymous, 13 years ago

Has patch: set

comment:11 by Preston Holmes, 13 years ago

Triage Stage: AcceptedReady for checkin

applied - built docs, reads well

comment:12 by Paul McMillan, 13 years ago

Resolution: fixed
Status: assignedclosed

In [16874]:

Fixed #15633 -- Improved docs for post_syncdb signal.

comment:13 by Paul McMillan, 13 years ago

In [16879]:

[1.3.X] Fixed #15633 -- Improved docs for post_syncdb signal. Thanks Justin Lilly for the patch.

Note: See TracTickets for help on using tickets.
Back to Top