Opened 5 years ago

Closed 5 years ago

#15113 closed (invalid)

post_sync signal's created_models are incorrect with flush

Reported by: dcramer Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The flush command calls emit_post_sync_signal with all models, which is incorrect. This can send models as being "created" which actually don't even exist on a database.

For example, given that we have a database called foo, which does not contain django.contrib.sites, and we run the flush command, it will pass all installed models to the create_default_site method, even though Site isnt available here. With this behavior, Site then tries to create a row on this database which throws a table does not exist error.

This can be fixed by changing the flush command to match the syncdb command so that it only passes created_models which are present on this database:

e.g. (taken from syncdb)

        all_models = [
            (app.__name__.split('.')[-2],
                [m for m in models.get_models(app, include_auto_created=True)
                if router.allow_syncdb(db, m)])
            for app in models.get_apps()
        ]

Attachments (1)

flush.diff (1.6 KB) - added by dcramer 5 years ago.
Diff against DISQUS codebase

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by dcramer

Diff against DISQUS codebase

comment:1 Changed 5 years ago by dcramer

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Already fixed in trunk :)

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