Code

#20748 closed Uncategorized (invalid)

model permissions created twice when codename has non-ASCII chars

Reported by: bpietro 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"

Attachments (0)

Change History (1)

comment:1 Changed 12 months ago by timo

  • Cc timograham@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.