Project

General

Profile

Development #9324

Permission needs unique index and partial unique indexes to prevent duplicate due to get_or_create()

Added by Benjamin Dauvergne over 3 years ago. Updated over 1 year ago.

Status:
Fermé
Priority:
Normal
Category:
-
Target version:
Start date:
14 Dec 2015
Due date:
% Done:

0%

Patch proposed:
No
Planning:
No

Description

get_or_create() is safe only if filtered keys covers at least a unique index (partial or not).

History

#1 Updated by Benjamin Dauvergne over 3 years ago

  • Status changed from Nouveau to Solution déployée

To find and remove existing duplicates:

delete from a2_rbac_permission where id in (select p.id from a2_rbac_role_permissions as rp right outer join a2_rbac_permission p on rp.permission_id = p.id left outer join a2_rbac_role as r on r.admin_scope_ct_id = 66 and r.admin_scope_id = p.id where rp.id is null and r.id is null);

commit 8a23dc8be0f9b1dd0995da6479bf439b9fc7c1e2
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Mon Dec 14 14:46:04 2015 +0100

    a2_rbac: add a partial index to prevent duplicate permissions (fixes #9234)

#2 Updated by Benjamin Dauvergne over 3 years ago

Le admin_scope_ct_id dans ma requête est à chercher dans django_content_type, c'est l'id du modèle a2_rbac.permission.

#3 Updated by Benjamin Dauvergne over 1 year ago

  • Status changed from Solution déployée to Fermé

Also available in: Atom PDF