Opened 14 years ago
Closed 11 years ago
#14028 closed Bug (fixed)
setting db_column to same value as another column should not validate
Reported by: | Anssi Kääriäinen | Owned by: | Helen Sherwood-Taylor |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2 |
Severity: | Normal | Keywords: | validation, sprintdec2010 |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Consider having a model
class FooBar(models.Model): foo = models.IntegerField() bar = models.IntegerField(db_column='foo') class Meta: db_table = 'foobar'
This does not raise any validation errors, even though the model clearly is not valid.
Change History (10)
comment:1 by , 14 years ago
Keywords: | sprintdec2010 added |
---|---|
Owner: | changed from | to
Summary: | setting db_column to same value than another column should not validate → setting db_column to same value as another column should not validate |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 11 years ago
Easy pickings: | set |
---|
Seems like this would be a fairly easy addition to django/core/management/validation.py with a test in django/tests/invalid_models/tests.py.
comment:6 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Working on this at the PyConUK Django sprint
comment:7 by , 11 years ago
Should it be valid to do something like this?
class FooBar(models.Model): foo = models.IntegerField(db_column='bar') bar = models.IntegerField(db_column='foo') class Meta: db_table = 'foobar'
i.e. should setting db_column on the first column 'free up' the name so the second one can use it?
comment:10 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Agreed, let's fix it. I'll work up a patch.