#37361 new Bug

Permission renames do not apply to a chain of RenameModel operations

Reported by: Jacob Walls Owned by:
Component: contrib.auth Version: 6.1
Severity: Release blocker Keywords:
Cc: artirix1927 Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

#27489 implemented renaming permissions as part of RenameModel migration operations, but did not support a chain of multiple operations.

For a chain of renames A -> B -> C, the database is queried for permissions on A, and then for permissions on B, but because all planned renames are applied to the database in a second loop, the query for permissions on B in the first loop finds nothing, so no second permission rename is done in the second loop.

To reproduce:

  1. Define Class A
  2. makemigrations
  3. migrate (this creates permissions)
  4. Rename A -> B
  5. makemigrations (answer "Y" to the rename prompt)
  6. Rename B -> C
  7. makemigrations (answer "Y" to the rename prompt)
  8. migrate -v2 (this renames permissions)

Expected: permissions in database end with "C"
Actual:

Renamed permission(s): myapp.add_a → add_b
Renamed permission(s): myapp.change_a → change_b
Renamed permission(s): myapp.delete_a → delete_b
Renamed permission(s): myapp.view_a → view_b
Adding permission 'Permission object (49)'
Adding permission 'Permission object (50)'
Adding permission 'Permission object (51)'
Adding permission 'Permission object (52)'
  1. migrate myapp zero
RuntimeError: 4 permission rename conflict(s) detected.

Bug in a040f555069971192220122555f187530d679d53.

Change History (0)

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