diff --git a/django-stubs/contrib/gis/db/models/aggregates.pyi b/django-stubs/contrib/gis/db/models/aggregates.pyi index d42cad7bb..0d1ca38b2 100644 --- a/django-stubs/contrib/gis/db/models/aggregates.pyi +++ b/django-stubs/contrib/gis/db/models/aggregates.pyi @@ -1,25 +1,10 @@ from typing import Any from django.db.models import Aggregate -from django.db.models.sql.compiler import _AsSqlType class GeoAggregate(Aggregate): - function: Any is_extent: bool - @property - def output_field(self) -> Any: ... - def as_sql( - self, compiler: Any, connection: Any, function: Any | None = ..., **extra_context: Any - ) -> _AsSqlType: ... def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any) -> Any: ... - def resolve_expression( - self, - query: Any | None = ..., - allow_joins: bool = ..., - reuse: Any | None = ..., - summarize: bool = ..., - for_save: bool = ..., - ) -> Any: ... class Collect(GeoAggregate): name: str diff --git a/django-stubs/contrib/gis/db/models/functions.pyi b/django-stubs/contrib/gis/db/models/functions.pyi index bc5b88d7f..89efe2d60 100644 --- a/django-stubs/contrib/gis/db/models/functions.pyi +++ b/django-stubs/contrib/gis/db/models/functions.pyi @@ -2,20 +2,13 @@ from typing import Any from django.db.models import Func from django.db.models import Transform as StandardTransform -from django.db.models.sql.compiler import _AsSqlType NUMERIC_TYPES: Any class GeoFuncMixin: - function: Any geom_param_pos: Any - def __init__(self, *expressions: Any, **extra: Any) -> None: ... @property def geo_field(self) -> Any: ... - def as_sql( - self, compiler: Any, connection: Any, function: Any | None = ..., **extra_context: Any - ) -> _AsSqlType: ... - def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ... class GeoFunc(GeoFuncMixin, Func): ... diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 8ccfa062f..b2be3de0f 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -115,6 +115,12 @@ class CombinedExpression(SQLiteNumericMixin, Expression): rhs: Combinable def __init__(self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Field | None = ...) -> None: ... +class DurationExpression(CombinedExpression): + def compile(self, side: Combinable, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... + +class TemporalSubtraction(CombinedExpression): + def __init__(self, lhs: Combinable, rhs: Combinable) -> None: ... + class F(Combinable): name: str def __init__(self, name: str) -> None: ... @@ -148,30 +154,24 @@ class OuterRef(F): contains_aggregate: bool def relabeled_clone(self: Self, relabels: Any) -> Self: ... -class Subquery(BaseExpression, Combinable): +class Func(SQLiteNumericMixin, Expression): + function: str + name: str template: str - query: Query + arg_joiner: str + arity: int | None + source_expressions: list[Expression] extra: dict[Any, Any] - def __init__(self, queryset: Query | QuerySet, output_field: Field | None = ..., **extra: Any) -> None: ... - -class Exists(Subquery): - negated: bool - def __init__(self, queryset: Query | QuerySet, negated: bool = ..., **kwargs: Any) -> None: ... - def __invert__(self) -> Exists: ... - -class OrderBy(Expression): - template: str - nulls_first: bool - nulls_last: bool - descending: bool - expression: Expression | F | Subquery - def __init__( + def __init__(self, *expressions: Any, output_field: Field | None = ..., **extra: Any) -> None: ... + def as_sql( self, - expression: Expression | F | Subquery, - descending: bool = ..., - nulls_first: bool = ..., - nulls_last: bool = ..., - ) -> None: ... + compiler: SQLCompiler, + connection: BaseDatabaseWrapper, + function: str | None = ..., + template: str | None = ..., + arg_joiner: str | None = ..., + **extra_context: Any, + ) -> _AsSqlType: ... class Value(Expression): value: Any @@ -182,15 +182,25 @@ class RawSQL(Expression): sql: str def __init__(self, sql: str, params: Sequence[Any], output_field: Field | None = ...) -> None: ... -class Func(SQLiteNumericMixin, Expression): - function: str - name: str - template: str - arg_joiner: str - arity: int | None - source_expressions: list[Expression] - extra: dict[Any, Any] - def __init__(self, *expressions: Any, output_field: Field | None = ..., **extra: Any) -> None: ... +class Star(Expression): ... + +class Col(Expression): + target: Field + alias: str + contains_column_references: Literal[True] + possibly_multivalued: Literal[False] + def __init__(self, alias: str, target: Field, output_field: Field | None = ...) -> None: ... + +class Ref(Expression): + def __init__(self, refs: str, source: Expression) -> None: ... + +class ExpressionList(Func): + def __init__(self, *expressions: BaseExpression | Combinable, **extra: Any) -> None: ... + +class OrderByList(Func): ... + +class ExpressionWrapper(Expression): + def __init__(self, expression: Q | Combinable, output_field: Field) -> None: ... class When(Expression): template: str @@ -208,21 +218,30 @@ class Case(Expression): self, *cases: Any, default: Any | None = ..., output_field: Field | None = ..., **extra: Any ) -> None: ... -class ExpressionWrapper(Expression): - def __init__(self, expression: Q | Combinable, output_field: Field) -> None: ... - -class Col(Expression): - target: Field - alias: str - contains_column_references: Literal[True] - possibly_multivalued: Literal[False] - def __init__(self, alias: str, target: Field, output_field: Field | None = ...) -> None: ... +class Subquery(BaseExpression, Combinable): + template: str + query: Query + extra: dict[Any, Any] + def __init__(self, queryset: Query | QuerySet, output_field: Field | None = ..., **extra: Any) -> None: ... -class Ref(Expression): - def __init__(self, refs: str, source: Expression) -> None: ... +class Exists(Subquery): + negated: bool + def __init__(self, queryset: Query | QuerySet, negated: bool = ..., **kwargs: Any) -> None: ... + def __invert__(self) -> Exists: ... -class ExpressionList(Func): - def __init__(self, *expressions: BaseExpression | Combinable, **extra: Any) -> None: ... +class OrderBy(Expression): + template: str + nulls_first: bool + nulls_last: bool + descending: bool + expression: Expression | F | Subquery + def __init__( + self, + expression: Expression | F | Subquery, + descending: bool = ..., + nulls_first: bool = ..., + nulls_last: bool = ..., + ) -> None: ... class Window(SQLiteNumericMixin, Expression): template: str