Opened 9 years ago

Closed 9 years ago

Last modified 2 years ago

#1503 closed defect (fixed)

model validation does not report duplicate auto-generated "id" column

Reported by: mir@… Owned by: adrian
Component: Database layer (models, ORM) Version: magic-removal
Severity: normal Keywords:
Cc: mir@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This is a complicated case ...

If you set up a model class with a field named "id" and without any primary key, Django will add an AutoField named "ID". This leads to a duplicate field name, producing strange effects (django.db.models.query.find_field will report that there's no "id" field at all ...) which are hard to hunt down.

Change History (2)

comment:1 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [3100]) Fixed #1503 -- Improved model validator to throw an error if a model doesn't manually define a primary key and has a field named 'id', which conflicts with the auto-primary-key convention. Thanks, mir@…

comment:2 Changed 2 years ago by anonymous

  • Easy pickings unset
  • UI/UX unset
Note: See TracTickets for help on using tickets.
Back to Top