mirror of https://github.com/django/django.git
Simplified some imports for database functions.
Used more specific modules to reduce the risk of circular imports.
This commit is contained in:
parent
36fceeec88
commit
99b3ab2781
|
@ -1,5 +1,5 @@
|
|||
"""Database functions that do comparisons or type conversions."""
|
||||
from django.db.models import Func
|
||||
from django.db.models.expressions import Func
|
||||
|
||||
|
||||
class Cast(Func):
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from datetime import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import (
|
||||
DateField, DateTimeField, DurationField, Field, Func, IntegerField,
|
||||
TimeField, Transform, fields,
|
||||
from django.db.models.expressions import Func
|
||||
from django.db.models.fields import (
|
||||
DateField, DateTimeField, DurationField, Field, IntegerField, TimeField,
|
||||
)
|
||||
from django.db.models.lookups import (
|
||||
YearExact, YearGt, YearGte, YearLt, YearLte,
|
||||
Transform, YearExact, YearGt, YearGte, YearLt, YearLte,
|
||||
)
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -157,7 +157,7 @@ ExtractIsoYear.register_lookup(YearLte)
|
|||
|
||||
class Now(Func):
|
||||
template = 'CURRENT_TIMESTAMP'
|
||||
output_field = fields.DateTimeField()
|
||||
output_field = DateTimeField()
|
||||
|
||||
def as_postgresql(self, compiler, connection, **extra_context):
|
||||
# PostgreSQL's CURRENT_TIMESTAMP means "the time at the start of the
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import math
|
||||
import sys
|
||||
|
||||
from django.db.models import (
|
||||
DecimalField, FloatField, Func, IntegerField, Transform,
|
||||
)
|
||||
from django.db.models.expressions import Func
|
||||
from django.db.models.fields import DecimalField, FloatField, IntegerField
|
||||
from django.db.models.functions import Cast
|
||||
from django.db.models.lookups import Transform
|
||||
|
||||
|
||||
class DecimalInputMixin:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.db.models import Func, IntegerField, Transform, Value, fields
|
||||
from django.db.models.expressions import Func, Value
|
||||
from django.db.models.fields import IntegerField
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.db.models.lookups import Transform
|
||||
|
||||
|
||||
class BytesToCharFieldConversionMixin:
|
||||
|
@ -124,7 +126,7 @@ class Length(Transform):
|
|||
"""Return the number of characters in the expression."""
|
||||
function = 'LENGTH'
|
||||
lookup_name = 'length'
|
||||
output_field = fields.IntegerField()
|
||||
output_field = IntegerField()
|
||||
|
||||
def as_mysql(self, compiler, connection, **extra_context):
|
||||
return super().as_sql(compiler, connection, function='CHAR_LENGTH', **extra_context)
|
||||
|
@ -207,7 +209,7 @@ class StrIndex(Func):
|
|||
"""
|
||||
function = 'INSTR'
|
||||
arity = 2
|
||||
output_field = fields.IntegerField()
|
||||
output_field = IntegerField()
|
||||
|
||||
def as_postgresql(self, compiler, connection, **extra_context):
|
||||
return super().as_sql(compiler, connection, function='STRPOS', **extra_context)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db.models import FloatField, Func, IntegerField
|
||||
from django.db.models.expressions import Func
|
||||
from django.db.models.fields import FloatField, IntegerField
|
||||
|
||||
__all__ = [
|
||||
'CumeDist', 'DenseRank', 'FirstValue', 'Lag', 'LastValue', 'Lead',
|
||||
|
|
Loading…
Reference in New Issue