#31200: Default permissions creation raises a DataError on excessively long
model
names
----------------------------------------------+------------------------
Reporter: Michael Mulholland | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 2.2
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 |
----------------------------------------------+------------------------
I stumbled across this while performing some migrations on models with
rather... descriptive names (my original model was dynamically created).
Anyway, it looks like in cases where a model name is just under the 100
character limit, and contrib.auth is used, the codenames generated for the
default permissions (ie. add_*, change_*, delete_*, view_*) can exceed the
maximum 100 characters on the Permission model.
As an example, the model below having a 98 character name allows
migrations to be generated, but upon running the migration, a database
error is raised when it tries to create permissions with codenames above
100 characters.
The model:
{{{
class
SomeExcessivelyDescriptiveModelWithAnAbsolutelyRidiculousNameThatCouldntEverNeedToBeNearlyThisLong(models.Model):
field1 = models.CharField(max_length=25)
}}}
The error:
{{{
django.db.utils.DataError: value too long for type character varying(100)
}}}
While I'm aware that you can override the default permissions by setting
Meta.default_permissions on the model (this is how I fixed my app), and
that the majority of people would never need model names this long, I
figured it might be worth adding validation for this case since it uses
contrib.auth's default behaviour. Also, the error message originally came
up while using a flush command, which seemed counterintuitive.
--
Ticket URL: <https://code.djangoproject.com/ticket/31200>
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/055.54c40a025f25616b4e30950d19cf93df%40djangoproject.com.