possible bug in model validation layer

4 views
Skip to first unread message

Waldemar Kornewald

unread,
Jan 9, 2010, 8:52:25 AM1/9/10
to django-developers
Hi,
the model validation layer checks for uniqueness of the primary_key
(in base.py: _perform_unique_checks()). But what if the pk value is
None (indicating for an AutoField that it should get an id from the
DB)?

Currently, it still issues a DB query testing if there's an entity
with a pk of None/NULL. Do some DBs allow for a nullable pk or is the
query executed unnecessarily?

Bye,
Waldemar Kornewald

Karen Tracey

unread,
Jan 9, 2010, 10:36:41 AM1/9/10
to django-d...@googlegroups.com

Actually MySQL in some cases will return the last inserted row for that query, making that query a really bad idea.  I have opened #12560 to track fixing this.

Thanks,
Karen
Reply all
Reply to author
Forward
0 new messages