Don't bother trying to validate uniqueness of autogenerated fields that have yet to be generated -- it doesn't make sense.
This should've been safe anyway - an autogenerated field would never be NULL, so the NULL value on a yet-to-be-added row should always be "unique".  But there is apparently a Django/MySQLdb/MySQL bug where the following query can return 1:
SELECT COUNT(*) FROM  WHERE .uid=67217(showard) gid=5000(eng) groups=7(lp),20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),60(games),499(google),5000(eng),5001(guest),5221(extmailproxy),5762(nonconf),6604(platformdocs),66815(kernel-testers),67686(autotest) IS NULL
This started happening when creating a job with a new one-time host.  The query would only return 1 once, subsequent identical queries would return 0.  That merits some further investigation, but this fixes the immediate problem.

Signed-off-by: Steve Howard <showard@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3752 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/model_logic.py b/frontend/afe/model_logic.py
index c0c623b..37c43d2 100644
--- a/frontend/afe/model_logic.py
+++ b/frontend/afe/model_logic.py
@@ -533,6 +533,11 @@
                 continue
 
             value = getattr(self, field_name)
+            if value is None and field_obj.auto_created:
+                # don't bother checking autoincrement fields about to be
+                # generated
+                continue
+
             existing_objs = manager.filter(**{field_name : value})
             num_existing = existing_objs.count()