1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Simplified imports from django.db and django.contrib.gis.db.

This commit is contained in:
Nick Pope
2019-08-20 08:54:41 +01:00
committed by Mariusz Felisiak
parent 469bf2db15
commit 335c9c94ac
113 changed files with 382 additions and 450 deletions

View File

@@ -3,8 +3,6 @@ import decimal
import unittest
from django.db import connection, models
from django.db.models import Avg
from django.db.models.expressions import Value
from django.db.models.functions import Cast
from django.test import (
TestCase, ignore_warnings, override_settings, skipUnlessDBFeature,
@@ -19,7 +17,7 @@ class CastTests(TestCase):
Author.objects.create(name='Bob', age=1, alias='1')
def test_cast_from_value(self):
numbers = Author.objects.annotate(cast_integer=Cast(Value('0'), models.IntegerField()))
numbers = Author.objects.annotate(cast_integer=Cast(models.Value('0'), models.IntegerField()))
self.assertEqual(numbers.get().cast_integer, 0)
def test_cast_from_field(self):
@@ -127,7 +125,7 @@ class CastTests(TestCase):
The SQL for the Cast expression is wrapped with parentheses in case
it's a complex expression.
"""
list(Author.objects.annotate(cast_float=Cast(Avg('age'), models.FloatField())))
list(Author.objects.annotate(cast_float=Cast(models.Avg('age'), models.FloatField())))
self.assertIn('(AVG("db_functions_author"."age"))::double precision', connection.queries[-1]['sql'])
def test_cast_to_text_field(self):