#22588 closed Bug (fixed)
makemigrations and regexvalidators
| Reported by: | leftmoose | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 1.7-beta-2 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
comparing RegexValidators doesn't quite work as expected, since it compares compiled instances
not sure why manage.py makemigrations still works (maybe re cache?), but the issue arises if e.g. using call_command(makemigrations)
cat app/models.py
from django.core import validators
from django.db import models
# Create your models here.
class MyModel(models.Model):
field = models.CharField(
max_length=1,
validators=[validators.RegexValidator('[A-Za-z]')],
)
(single shell session, no changes in the background)
In [1]: from django.core.management import call_command
In [2]: call_command('makemigrations')
Migrations for 'app':
0001_initial.py:
- Create model MyModel
In [3]: call_command('makemigrations')
Migrations for 'app':
0002_auto_20140506_2031.py:
- Alter field field on mymodel
In [4]: call_command('makemigrations')
Migrations for 'app':
0003_auto_20140506_2032.py:
- Alter field field on mymodel
In [5]: call_command('makemigrations')
Migrations for 'app':
0004_auto_20140506_2032.py:
- Alter field field on mymodel
Change History (9)
comment:1 by , 12 years ago
comment:2 by , 11 years ago
| Patch needs improvement: | set |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
comment:3 by , 11 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
This is a duplicate of the issue in #21638, and I've verified that on master it works as expected (I suspect, leftmoose, you're using the beta, where this wasn't fixed yet). Closing as WORKSFORME.
comment:4 by , 11 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → new |
@andrewgodwin, if you look at my patch, it sits on top of the fix from #21638. this is not a duplicate. a68f32579145dfbd51d87e14f9b5e04c770f9081 compares regex pattern objects, which i change to comparing their parameters. since a68f325 the regex validator has also grown an inverse_match argument, which is ignored. finally, you added __eq__, but no __ne__ which means assertNotEquals don't work properly. please see the pr above
comment:5 by , 11 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:6 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:9 by , 11 years ago
Sorry, my bad - we've had the "validators don't compare properly" reopened multiple times recently with people using the beta rather than master. A more descriptive title might have helped, though :)
I've merged in the PR and forward-ported it to master. Let me know if you see anything else wrong.
https://github.com/django/django/pull/2637