diff options
| author | Bendeguz Csirmaz <csirmazbendeguz@gmail.com> | 2025-01-10 08:44:10 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-10 11:43:38 +0100 |
| commit | 8287fd49151b1b99045efbf3de8ef911d63c5f45 (patch) | |
| tree | ac8238b9808fe4eb09ef362a83d181affa9498db /tests/basic/tests.py | |
| parent | 9fa4d07ce0729850661a31a6b37c6b48f13d2266 (diff) | |
Refs #36064 -- Added test that falsey primary key default/db_default value skips an update query on save.
This adds test coverage for logic change in 9fa4d07ce0729850661a31a6b37c6b48f13d2266.
Diffstat (limited to 'tests/basic/tests.py')
| -rw-r--r-- | tests/basic/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index cb267be0b1..6c2f9f2bd2 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -32,6 +32,8 @@ from .models import ( FeaturedArticle, PrimaryKeyWithDbDefault, PrimaryKeyWithDefault, + PrimaryKeyWithFalseyDbDefault, + PrimaryKeyWithFalseyDefault, SelfRef, ) @@ -203,6 +205,14 @@ class ModelInstanceCreationTests(TestCase): with self.assertNumQueries(2): ChildPrimaryKeyWithDefault().save() + def test_save_primary_with_falsey_default(self): + with self.assertNumQueries(1): + PrimaryKeyWithFalseyDefault().save() + + def test_save_primary_with_falsey_db_default(self): + with self.assertNumQueries(1): + PrimaryKeyWithFalseyDbDefault().save() + def test_save_deprecation(self): a = Article(headline="original", pub_date=datetime(2014, 5, 16)) msg = "Passing positional arguments to save() is deprecated" |
