-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
CLICKHOUSE_ENABLE_UPDATE_ROWCOUNT
django setting
- Loading branch information
Showing
7 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from clickhouse_backend.utils.version import get_version | ||
|
||
VERSION = (1, 1, 5, "final", 0) | ||
VERSION = (1, 1, 6, "final", 0) | ||
|
||
__version__ = get_version(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.db import models | ||
|
||
|
||
class Author(models.Model): | ||
name = models.CharField(max_length=10) | ||
num = models.IntegerField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.test import TestCase | ||
|
||
from . import models | ||
|
||
|
||
class QueriesTests(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.a1 = models.Author.objects.create(name="a1", num=1001) | ||
|
||
def test_update(self): | ||
with self.settings(CLICKHOUSE_ENABLE_UPDATE_ROWCOUNT=True): | ||
self.assertEqual(models.Author.objects.update(name="a11"), 1) | ||
with self.assertNumQueries(1): | ||
self.a1.save() | ||
self.a1.refresh_from_db() | ||
with self.settings(CLICKHOUSE_ENABLE_UPDATE_ROWCOUNT=False): | ||
self.assertEqual(models.Author.objects.update(name="a11"), -1) | ||
with self.assertNumQueries(2): | ||
self.a1.save() | ||
with self.assertRaises(models.Author.MultipleObjectsReturned): | ||
self.a1.refresh_from_db() |