Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
r12227 - in django/trunk: . django/db/models tests/modeltests/validation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
nore...@djangoproject.com  
View profile  
 More options Jan 14 2010, 12:04 pm
From: nore...@djangoproject.com
Date: Thu, 14 Jan 2010 11:04:54 -0600 (CST)
Local: Thurs, Jan 14 2010 12:04 pm
Subject: [Changeset] r12227 - in django/trunk: . django/db/models tests/modeltests/validation
Author: jkocherhans
Date: 2010-01-14 11:04:53 -0600 (Thu, 14 Jan 2010)
New Revision: 12227

Modified:
   django/trunk/AUTHORS
   django/trunk/django/db/models/base.py
   django/trunk/tests/modeltests/validation/test_unique.py
Log:
Fixed #12560. Changed validate_unique to stop checking null primary key values. Thanks, Honza Kr?\195?\161l.

Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS        2010-01-14 14:55:36 UTC (rev 12226)
+++ django/trunk/AUTHORS        2010-01-14 17:04:53 UTC (rev 12227)
@@ -256,7 +256,7 @@
     Gasper Koren
     Martin Kosír <mar...@martinkosir.net>
     Arthur Koziel <http://arthurkoziel.com>
-    Honza Kral <honza.k...@gmail.com>
+    Honza Král <honza.k...@gmail.com>
     Meir Kriheli <http://mksoft.co.il/>
     Bruce Kroeze <http://coderseye.com/>
     krzysiek.paw...@silvermedia.pl

Modified: django/trunk/django/db/models/base.py
===================================================================
--- django/trunk/django/db/models/base.py       2010-01-14 14:55:36 UTC (rev 12226)
+++ django/trunk/django/db/models/base.py       2010-01-14 17:04:53 UTC (rev 12227)
@@ -715,7 +715,7 @@
             for field_name in unique_check:
                 f = self._meta.get_field(field_name)
                 lookup_value = getattr(self, f.attname)
-                if f.null and lookup_value is None:
+                if lookup_value is None:
                     # no value, skip the lookup
                     continue
                 if f.primary_key and not getattr(self, '_adding', False):

Modified: django/trunk/tests/modeltests/validation/test_unique.py
===================================================================
--- django/trunk/tests/modeltests/validation/test_unique.py     2010-01-14 14:55:36 UTC (rev 12226)
+++ django/trunk/tests/modeltests/validation/test_unique.py     2010-01-14 17:04:53 UTC (rev 12227)
@@ -43,18 +43,26 @@
         settings.DEBUG = self._old_debug
         super(PerformUniqueChecksTest, self).tearDown()

-    def test_primary_key_unique_check_performed_when_adding(self):
-        """Regression test for #12132"""
-        l = len(connection.queries)
+    def test_primary_key_unique_check_not_performed_when_adding_and_pk_not_specifie d(self):
+        # Regression test for #12560
+        query_count = len(connection.queries)
         mtv = ModelToValidate(number=10, name='Some Name')
         setattr(mtv, '_adding', True)
         mtv.full_clean()
-        self.assertEqual(l+1, len(connection.queries))
+        self.assertEqual(query_count, len(connection.queries))

+    def test_primary_key_unique_check_performed_when_adding_and_pk_specified(self):
+        # Regression test for #12560
+        query_count = len(connection.queries)
+        mtv = ModelToValidate(number=10, name='Some Name', id=123)
+        setattr(mtv, '_adding', True)
+        mtv.full_clean()
+        self.assertEqual(query_count + 1, len(connection.queries))
+
     def test_primary_key_unique_check_not_performed_when_not_adding(self):
-        """Regression test for #12132"""
-        l = len(connection.queries)
+        # Regression test for #12132
+        query_count= len(connection.queries)
         mtv = ModelToValidate(number=10, name='Some Name')
         mtv.full_clean()
-        self.assertEqual(l, len(connection.queries))
+        self.assertEqual(query_count, len(connection.queries))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »