﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15884	Model validation allows nullable primary key field.	JustinTArthur	JustinTArthur	"If I have a primary key field that is also nullable, the model validation code is currently allowing it:
{{{
#!python
class MyModel(models.Model):
    other_model = OneToOneField(OtherModel, primary_key=True, null=True)
}}}

This behavior seems like a defect given two circumstances:
 * No SQL implementation I know of allows a primary key column to be `NULL` in the schema.
 * Django's `CASCADE` deletion will `None`/`NULL` out any `null=True` foreign keys (see source:/trunk/django/db/models/deletion.py@15927#L19), 
  * While a SQL backend might correctly map the `None` to a `0` instead of `NULL` in the `UPDATE` statement, after a second deletion against the same table, you would have more than one row with primary key of `0`, thus violating the uniqueness constraint intrinsic to a primary key field."	Bug	closed	Database layer (models, ORM)	1.3	Normal	fixed		julie@… alexandrul	Ready for checkin	1	0	0	0	0	0
