diff --git a/django/db/models/base.py b/django/db/models/base.py
index 06db7cc..dcc1ca2 100644
a
|
b
|
class Model(object):
|
696 | 696 | for field_name in unique_check: |
697 | 697 | f = self._meta.get_field(field_name) |
698 | 698 | lookup_value = getattr(self, f.attname) |
699 | | if f.null and lookup_value is None: |
| 699 | if lookup_value is None: |
700 | 700 | # no value, skip the lookup |
701 | 701 | continue |
702 | 702 | if f.primary_key and not getattr(self, '_adding', False): |
diff --git a/tests/modeltests/validation/test_unique.py b/tests/modeltests/validation/test_unique.py
index cbb56aa..8ae946c 100644
a
|
b
|
class PerformUniqueChecksTest(unittest.TestCase):
|
42 | 42 | settings.DEBUG = self._old_debug |
43 | 43 | super(PerformUniqueChecksTest, self).tearDown() |
44 | 44 | |
45 | | def test_primary_key_unique_check_performed_when_adding(self): |
| 45 | def test_primary_key_unique_check_not_performed_when_adding_and_pk_not_specified(self): |
46 | 46 | """Regression test for #12132""" |
47 | 47 | l = len(connection.queries) |
48 | 48 | mtv = ModelToValidate(number=10, name='Some Name') |
49 | 49 | setattr(mtv, '_adding', True) |
50 | 50 | mtv.full_validate() |
| 51 | self.assertEqual(l, len(connection.queries)) |
| 52 | |
| 53 | def test_primary_key_unique_check_performed_when_adding_and_pk_specified(self): |
| 54 | """Regression test for #12132""" |
| 55 | l = len(connection.queries) |
| 56 | mtv = ModelToValidate(number=10, name='Some Name', id=123) |
| 57 | setattr(mtv, '_adding', True) |
| 58 | mtv.full_validate() |
51 | 59 | self.assertEqual(l+1, len(connection.queries)) |
52 | 60 | |
53 | 61 | def test_primary_key_unique_check_not_performed_when_not_adding(self): |