from collections.abc import Iterable
from typing import Any

from django.db.models.base import Model
from django.db.models.expressions import Case
from django.db.models.fields import Field
from django.db.models.query import QuerySet
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode

class DeleteQuery(Query):
    select: tuple[Any, ...]
    where_class: type[WhereNode]
    where: WhereNode = ...
    def do_query(self, table: str, where: WhereNode, using: str) -> int: ...
    def delete_batch(self, pk_list: list[int] | list[str], using: str) -> int: ...
    def delete_qs(self, query: QuerySet[Any], using: str) -> int: ...

class UpdateQuery(Query):
    select: tuple[Any, ...]
    where_class: type[WhereNode]
    def __init__(self, *args: Any, **kwargs: Any) -> None: ...
    where: WhereNode = ...
    def update_batch(
        self, pk_list: list[int], values: dict[str, int | None], using: str
    ) -> None: ...
    def add_update_values(self, values: dict[str, Any]) -> None: ...
    def add_update_fields(
        self, values_seq: list[tuple[Field[Any, Any], type[Model] | None, Case]]
    ) -> None: ...
    def add_related_update(
        self, model: type[Model], field: Field[Any, Any], value: int | str
    ) -> None: ...
    def get_related_updates(self) -> list[UpdateQuery]: ...

class InsertQuery(Query):
    select: tuple[Any, ...]
    where: WhereNode
    where_class: type[WhereNode]
    fields: Iterable[Field[Any, Any]] = ...
    objs: list[Model] = ...
    raw: bool = ...
    def __init__(self, *args: Any, **kwargs: Any) -> None: ...
    def insert_values(
        self, fields: Iterable[Field[Any, Any]], objs: list[Model], raw: bool = ...
    ) -> None: ...

class AggregateQuery(Query):
    select: tuple[Any, ...]
    sub_params: tuple[Any, ...]
    where: WhereNode
    where_class: type[WhereNode]
    def add_subquery(self, query: Query, using: str) -> None: ...
