Opened 11 years ago

Closed 11 years ago

#20748 closed Uncategorized (invalid)

model permissions created twice when codename has non-ASCII chars

Reported by: Pietro Bernardi Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: permission codename, non-ASCII
Cc: timograham@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Creating some model permissions I wrongly created one with codename with non-ASCII char.
syncdb created this permission without any error.
Subsequent call of syncdb tries to create it once more, I think, becuse I got error

django.db.utils.IntegrityError: duplicate key value violates unique constraint "auth_permission_content_type_id_key"
DETAIL: Key (content_type_id, codename)=(73, dati_per_contabilità) already exists.

Used RDBMS PostgreSQL with psycopg2 backend
After corrected typo all is OK, so really this non-ASCII was the guilty.

IMHO should be better reject it in first run with "Error - only ASCII chars allowed in codename"

Change History (1)

comment:1 by Tim Graham, 11 years ago

Cc: timograham@… added
Resolution: invalid
Status: newclosed

How did you declare the permission? I was able to reproduce the issue like this:

permissions = (
    ('foo à', 'My Permission'),
)

but when I prefixed the first string so that it was unicode (u'foo à'), this fixed the issue.

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