#31320: Prevent BEGIN and COMMIT in RunSQL in atomic migrations
-------------------------------------------------+------------------------
Reporter: Adam (Chainz) Johnson | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+------------------------
Migrations are `atomic` by default, which means they use a transaction on
backends that support them (PostgreSQL).
`RunSQL` allows running arbitrary SQL, including `BEGIN` / `COMMIT` which
break the atomic transaction handling.
PostgreSQL will warn about `BEGIN` within a transaction (
https://www.postgresql.org/docs/current/sql-begin.html ) but this warning
won't be displayed on a standard Django setup. Equally it will warn about
a `COMMIT` when no transaction is running.
(SQLite at least raises an error for a `BEGIN` within a transaction).
Beginners to the migration framework can miss that migrations are 'atomic'
by default, and use their SQL knowledge to write `BEGIN`/`COMMIT`, not
realizing they're actually breaking the transactional integrity of their
migrations.
It would be good to detect this and refuse to run such `RunSQL`
operations.
--
Ticket URL: <https://code.djangoproject.com/ticket/31320>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.1c814455fc280e507f2cd3ecbd97a9e9%40djangoproject.com.