mirror of
https://github.com/django/django.git
synced 2025-04-19 23:04:36 +00:00
Removed unnecessary usage of .extra() in tests.
This commit is contained in:
parent
ac5e56a47f
commit
5d539daa56
@ -19,6 +19,7 @@ from django.db import (
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.backends.signals import connection_created
|
||||
from django.db.backends.utils import CursorWrapper
|
||||
from django.db.models import Value
|
||||
from django.db.models.sql.constants import CURSOR
|
||||
from django.test import (
|
||||
TestCase,
|
||||
@ -84,8 +85,10 @@ class LastExecutedQueryTest(TestCase):
|
||||
|
||||
def test_query_encoding(self):
|
||||
"""last_executed_query() returns a string."""
|
||||
data = RawData.objects.filter(raw_data=b"\x00\x46 \xFE").extra(
|
||||
select={"föö": 1}
|
||||
data = RawData.objects.filter(raw_data=b"\x00\x46 \xFE").annotate(
|
||||
**{
|
||||
"föö": Value(1),
|
||||
}
|
||||
)
|
||||
sql, params = data.query.sql_with_params()
|
||||
with data.query.get_compiler("default").execute_sql(CURSOR) as cursor:
|
||||
|
@ -53,6 +53,7 @@ from django.db.models import (
|
||||
UUIDField,
|
||||
Value,
|
||||
)
|
||||
from django.db.models.expressions import RawSQL
|
||||
from django.db.models.fields.json import KT, KeyTextTransform
|
||||
from django.db.models.functions import (
|
||||
Abs,
|
||||
@ -774,7 +775,9 @@ class SchemaTests(TransactionTestCase):
|
||||
field_type, connection.features.introspected_field_types["IntegerField"]
|
||||
)
|
||||
# Make sure the values were transformed correctly
|
||||
self.assertEqual(Author.objects.extra(where=["thing = 1"]).count(), 2)
|
||||
self.assertEqual(
|
||||
Author.objects.filter(RawSQL("thing = %s", (1,), BooleanField())).count(), 2
|
||||
)
|
||||
|
||||
def test_add_field_o2o_nullable(self):
|
||||
with connection.schema_editor() as editor:
|
||||
|
Loading…
x
Reference in New Issue
Block a user