non-null FK to a CharField primary key fails when key value is the empty string, giving "[model.fk_col] may not be NULL"
|Reported by:||andrewbadr||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.1|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Model A has a CharField primary_key. Model B has a ForeignKey field to model A. If an instance of A has a row with an empty-string in the primary key column, no B instance can point to it. Attempting to create such a B instance fails with "[model.fk_col] may not be NULL". Repro'd with PG and sqlite3.
Change History (8)
comment:1 Changed 6 years ago by andrewbadr
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 5 years ago by jacob
- Triage Stage changed from Unreviewed to Design decision needed