Opened 7 years ago

Closed 7 years ago

#27507 closed Cleanup/optimization (fixed)

use SchemaEditor.execute() to run deferred_sql in migration sync_apps

Reported by: Lex Berezhny Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Associated GitHub Pull Request: https://github.com/django/django/pull/7579

This is a very simple fix for the sync_app method in the migration command that uses editor.execute() to execute deferred sql instead of directly using cursor.execute().

There are two reasons for this:

  1. This is consistent with the normal migrateable apps workflow where deferred SQL is executed using editor.execute(). See: [django/db/backends/base/schema.py#L91](https://github.com/django/django/blob/371adc472a2a1f09923101e3c4fda60cdff96028/django/db/backends/base/schema.py#L91)
  1. When cursor.execute() is hard coded in sync_app it is not possible to do custom processing of the SQL (as could be done with a custom DatabaseSchemaEditor.execute()).

This pull request does not change any existing functionality and is backwards compatible but it provides a more consistent, intuitive and predictable behavior when extending DatabaseSchemaEditor.

Change History (2)

comment:1 by Claude Paroz, 7 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 8eb56f3c:

Fixed #27507 -- Used SchemaEditor.execute() to run deferred_sql in migrate's sync_apps().

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