#34351: Slash in constraint name results in invalid migration file naming
-------------------------------------+-------------------------------------
Reporter: sdupouy | Owner: nobody
Type: Bug | Status: new
Component: | Version: 4.1
Migrations | Keywords: constraint name
Severity: Normal | slash
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
== Steps to reproduce:
1. create a model
{{{#!python
class TestModel(models.Model):
foo = models.TextField()
bar = models.TextField()
}}}
2. make and apply the initial migration
3. add a constraint with a forward slash in its name
{{{#!python
class TestModel(models.Model):
foo = models.TextField()
bar = models.TextField()
class Meta:
constraints = [
models.UniqueConstraint(fields=['foo', 'bar'], name='foo/bar
unique')
]
}}}
4. `makemigrations` and `migrate`
== Result
Django tries to create a migration file named `0002_testmodel_foo/bar
unique.py`.
This results in the creation of the file `bar unique.py` in the directory
`0002_testmodel_foo`.
Hence, the last `migrate` command doesn't work.
== Expected behavior
Creation of a migration file with a sanitized name, or a warning that the
constraint name shouldn't contain special characters.
== Remark
All that the documentation says on constraint names is
**BaseConstraint.name**
The name of the constraint. You must always specify a unique name for
the constraint.
It isn't stated that the naming of constraints must follow specific
conventions.
--
Ticket URL: <https://code.djangoproject.com/ticket/34351>
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/0107018664da2dd4-c92d302e-0d5c-4485-8bed-6b693142d800-000000%40eu-central-1.amazonses.com.