This commit is contained in:
Maxim Kurnikov
2018-08-14 12:09:47 +03:00
parent a13d4c352a
commit ca5f489092
3 changed files with 368 additions and 464 deletions

View File

@@ -8,6 +8,7 @@ from django.core.validators import DecimalValidator
from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.expressions import Col, CombinedExpression from django.db.models.expressions import Col, CombinedExpression
from django.db.models.fields import reverse_related
from django.db.models.fields.files import FieldFile from django.db.models.fields.files import FieldFile
from django.db.models.fields.reverse_related import ForeignObjectRel from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.query import QuerySet from django.db.models.query import QuerySet

View File

@@ -1,3 +1,5 @@
import decimal
import operator
from collections import OrderedDict from collections import OrderedDict
from datetime import date, datetime from datetime import date, datetime
from decimal import Decimal from decimal import Decimal
@@ -11,8 +13,6 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.models.base import Model, ModelState from django.db.models.base import Model, ModelState
from django.db.models.expressions import Expression from django.db.models.expressions import Expression
from django.db.models.fields import Field from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignKey
from django.db.models.fields.related_descriptors import (ForwardManyToOneDescriptor, from django.db.models.fields.related_descriptors import (ForwardManyToOneDescriptor,
ReverseOneToOneDescriptor) ReverseOneToOneDescriptor)
from django.db.models.query_utils import Q from django.db.models.query_utils import Q
@@ -21,206 +21,277 @@ from django.db.models.sql.query import Query, RawQuery
REPR_OUTPUT_SIZE: int REPR_OUTPUT_SIZE: int
EmptyResultSet: Any EmptyResultSet: Any
class BaseIterable: class BaseIterable:
queryset: Any = ... queryset: Any = ...
chunked_fetch: Any = ... chunked_fetch: Any = ...
chunk_size: Any = ... chunk_size: Any = ...
def __init__( def __init__(
self, self,
queryset: QuerySet, queryset: QuerySet,
chunked_fetch: bool = ..., chunked_fetch: bool = ...,
chunk_size: int = ..., chunk_size: int = ...,
) -> None: ... ) -> None: ...
class ModelIterable(BaseIterable): class ModelIterable(BaseIterable):
chunk_size: int chunk_size: int
chunked_fetch: bool chunked_fetch: bool
queryset: django.db.models.query.QuerySet queryset: django.db.models.query.QuerySet
def __iter__(self) -> Iterator[Model]: ... def __iter__(self) -> Iterator[Model]: ...
class ValuesIterable(BaseIterable): class ValuesIterable(BaseIterable):
chunk_size: int chunk_size: int
chunked_fetch: bool chunked_fetch: bool
queryset: django.db.models.query.QuerySet queryset: django.db.models.query.QuerySet
def __iter__(self) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ... def __iter__(self) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
class ValuesListIterable(BaseIterable): class ValuesListIterable(BaseIterable):
chunk_size: int chunk_size: int
chunked_fetch: bool chunked_fetch: bool
queryset: django.db.models.query.QuerySet queryset: django.db.models.query.QuerySet
def __iter__(self) -> Union[chain, map]: ... def __iter__(self) -> Union[chain, map]: ...
class NamedValuesListIterable(ValuesListIterable): class NamedValuesListIterable(ValuesListIterable):
chunk_size: int chunk_size: int
chunked_fetch: bool chunked_fetch: bool
queryset: django.db.models.query.QuerySet queryset: QuerySet
@staticmethod @staticmethod
def create_namedtuple_class(*names: Any) -> Any: ... def create_namedtuple_class(*names: Any) -> Any: ...
def __iter__(self) -> Any: ... def __iter__(self) -> Any: ...
class FlatValuesListIterable(BaseIterable): class FlatValuesListIterable(BaseIterable):
chunk_size: int chunk_size: int
chunked_fetch: bool chunked_fetch: bool
queryset: django.db.models.query.QuerySet queryset: QuerySet
def __iter__(self) -> Iterator[Any]: ... def __iter__(self) -> Iterator[Any]: ...
class QuerySet: class QuerySet:
model: Optional[Type[django.db.models.base.Model]] = ... model: Optional[Type[django.db.models.base.Model]] = ...
query: django.db.models.sql.query.Query = ... query: django.db.models.sql.query.Query = ...
def __init__( def __init__(
self, self,
model: Optional[Type[Model]] = ..., model: Optional[Type[Model]] = ...,
query: Optional[Query] = ..., query: Optional[Query] = ...,
using: Optional[str] = ..., using: Optional[str] = ...,
hints: Optional[Dict[str, Model]] = ..., hints: Optional[Dict[str, Model]] = ...,
) -> None: ... ) -> None: ...
def as_manager(cls): ... def as_manager(cls): ...
as_manager: Any = ... as_manager: Any = ...
def __deepcopy__( def __deepcopy__(
self, self,
memo: Dict[ memo: Dict[
int, int,
Union[ Union[
Dict[str, Union[ModelState, int, str]], Dict[str, Union[ModelState, int, str]],
List[Union[Dict[str, Union[bool, str]], ModelState]], List[Union[Dict[str, Union[bool, str]], ModelState]],
Model, Model,
ModelState, ModelState,
],
], ],
],
) -> QuerySet: ... ) -> QuerySet: ...
def __len__(self) -> int: ... def __len__(self) -> int: ...
def __iter__(self) -> Any: ... def __iter__(self) -> Any: ...
def __bool__(self) -> bool: ... def __bool__(self) -> bool: ...
def __getitem__(self, k: Union[int, slice, str]) -> Any: ... def __getitem__(self, k: Union[int, slice, str]) -> Any: ...
def __and__(self, other: QuerySet) -> QuerySet: ... def __and__(self, other: QuerySet) -> QuerySet: ...
def __or__(self, other: QuerySet) -> QuerySet: ... def __or__(self, other: QuerySet) -> QuerySet: ...
def iterator(self, chunk_size: int = ...) -> Iterator[Any]: ... def iterator(self, chunk_size: int = ...) -> Iterator[Any]: ...
def aggregate( def aggregate(
self, *args: Any, **kwargs: Any self, *args: Any, **kwargs: Any
) -> Dict[str, Optional[Union[datetime, float]]]: ... ) -> Dict[str, Optional[Union[datetime, float]]]: ...
def count(self) -> int: ... def count(self) -> int: ...
def get( def get(
self, *args: Any, **kwargs: Any self, *args: Any, **kwargs: Any
) -> Union[ ) -> Union[
Dict[str, Union[date, Decimal, float, str]], Dict[str, Union[date, Decimal, float, str]],
Tuple[Union[Decimal, str]], Tuple[Union[Decimal, str]],
Model, Model,
str, str,
]: ... ]: ...
def create(self, **kwargs: Any) -> Model: ... def create(self, **kwargs: Any) -> Model: ...
def bulk_create( def bulk_create(
self, self,
objs: Union[Iterator[Any], List[Model]], objs: Union[Iterator[Any], List[Model]],
batch_size: Optional[int] = ..., batch_size: Optional[int] = ...,
) -> List[Model]: ... ) -> List[Model]: ...
def get_or_create( def get_or_create(
self, self,
defaults: Optional[Union[Dict[str, date], Dict[str, Model]]] = ..., defaults: Optional[Union[Dict[str, date], Dict[str, Model]]] = ...,
**kwargs: Any **kwargs: Any
) -> Tuple[Model, bool]: ... ) -> Tuple[Model, bool]: ...
def update_or_create( def update_or_create(
self, self,
defaults: Optional[ defaults: Optional[
Union[ Union[
Dict[str, Callable], Dict[str, Callable],
Dict[str, date], Dict[str, date],
Dict[str, Model], Dict[str, Model],
Dict[str, str], Dict[str, str],
] ]
] = ..., ] = ...,
**kwargs: Any **kwargs: Any
) -> Tuple[Model, bool]: ... ) -> Tuple[Model, bool]: ...
def earliest( def earliest(
self, *fields: Any, field_name: Optional[Any] = ... self, *fields: Any, field_name: Optional[Any] = ...
) -> Model: ... ) -> Model: ...
def latest( def latest(
self, *fields: Any, field_name: Optional[Any] = ... self, *fields: Any, field_name: Optional[Any] = ...
) -> Model: ... ) -> Model: ...
def first(self) -> Optional[Union[Dict[str, int], Model]]: ... def first(self) -> Optional[Union[Dict[str, int], Model]]: ...
def last(self) -> Optional[Model]: ... def last(self) -> Optional[Model]: ...
def in_bulk( def in_bulk(
self, id_list: Any = ..., *, field_name: str = ... self, id_list: Any = ..., *, field_name: str = ...
) -> Union[Dict[int, Model], Dict[str, Model]]: ... ) -> Union[Dict[int, Model], Dict[str, Model]]: ...
def delete(self) -> Tuple[int, Dict[str, int]]: ... def delete(self) -> Tuple[int, Dict[str, int]]: ...
def update(self, **kwargs: Any) -> int: ... def update(self, **kwargs: Any) -> int: ...
def exists(self) -> bool: ... def exists(self) -> bool: ...
def explain( def explain(
self, *, format: Optional[Any] = ..., **options: Any self, *, format: Optional[Any] = ..., **options: Any
) -> str: ... ) -> str: ...
def raw( def raw(
self, self,
raw_query: str, raw_query: str,
params: Optional[ params: Optional[
Union[ Union[
Dict[str, str], Dict[str, str],
List[datetime], List[datetime],
List[Decimal], List[Decimal],
List[str], List[str],
Set[str], Set[str],
Tuple[int], Tuple[int],
] ]
] = ..., ] = ...,
translations: Optional[Dict[str, str]] = ..., translations: Optional[Dict[str, str]] = ...,
using: None = ..., using: None = ...,
) -> RawQuerySet: ... ) -> RawQuerySet: ...
def values(self, *fields: Any, **expressions: Any) -> QuerySet: ... def values(self, *fields: Any, **expressions: Any) -> QuerySet: ...
def values_list( def values_list(
self, *fields: Any, flat: bool = ..., named: bool = ... self, *fields: Any, flat: bool = ..., named: bool = ...
) -> QuerySet: ... ) -> QuerySet: ...
def dates( def dates(
self, field_name: str, kind: str, order: str = ... self, field_name: str, kind: str, order: str = ...
) -> QuerySet: ... ) -> QuerySet: ...
def datetimes( def datetimes(
self, field_name: str, kind: str, order: str = ..., tzinfo: None = ... self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...
) -> QuerySet: ... ) -> QuerySet: ...
def none(self) -> QuerySet: ... def none(self) -> QuerySet: ...
def all(self) -> QuerySet: ... def all(self) -> QuerySet: ...
def filter(self, *args: Any, **kwargs: Any) -> QuerySet: ... def filter(self, *args: Any, **kwargs: Any) -> QuerySet: ...
def exclude(self, *args: Any, **kwargs: Any) -> QuerySet: ... def exclude(self, *args: Any, **kwargs: Any) -> QuerySet: ...
def complex_filter( def complex_filter(
self, self,
filter_obj: Union[ filter_obj: Union[
Dict[str, datetime], Dict[str, QuerySet], Q, MagicMock Dict[str, datetime], Dict[str, QuerySet], Q, MagicMock
], ],
) -> QuerySet: ... ) -> QuerySet: ...
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet: ... def union(self, *other_qs: Any, all: bool = ...) -> QuerySet: ...
def intersection(self, *other_qs: Any) -> QuerySet: ... def intersection(self, *other_qs: Any) -> QuerySet: ...
def difference(self, *other_qs: Any) -> QuerySet: ... def difference(self, *other_qs: Any) -> QuerySet: ...
def select_for_update( def select_for_update(
self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ... self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...
) -> QuerySet: ... ) -> QuerySet: ...
def select_related(self, *fields: Any) -> QuerySet: ... def select_related(self, *fields: Any) -> QuerySet: ...
def prefetch_related(self, *lookups: Any) -> QuerySet: ... def prefetch_related(self, *lookups: Any) -> QuerySet: ...
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet: ... def annotate(self, *args: Any, **kwargs: Any) -> QuerySet: ...
def order_by(self, *field_names: Any) -> QuerySet: ... def order_by(self, *field_names: Any) -> QuerySet: ...
def distinct(self, *field_names: Any) -> QuerySet: ... def distinct(self, *field_names: Any) -> QuerySet: ...
def extra( def extra(
self, self,
select: Optional[ select: Optional[
Union[Dict[str, int], Dict[str, str], OrderedDict] Union[Dict[str, int], Dict[str, str], OrderedDict]
] = ..., ] = ...,
where: Optional[List[str]] = ..., where: Optional[List[str]] = ...,
params: Optional[Union[List[int], List[str]]] = ..., params: Optional[Union[List[int], List[str]]] = ...,
tables: Optional[List[str]] = ..., tables: Optional[List[str]] = ...,
order_by: Optional[Union[List[str], Tuple[str]]] = ..., order_by: Optional[Union[List[str], Tuple[str]]] = ...,
select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ..., select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ...,
) -> QuerySet: ... ) -> QuerySet: ...
def reverse(self) -> QuerySet: ... def reverse(self) -> QuerySet: ...
def defer(self, *fields: Any) -> QuerySet: ... def defer(self, *fields: Any) -> QuerySet: ...
def only(self, *fields: Any) -> QuerySet: ... def only(self, *fields: Any) -> QuerySet: ...
def using(self, alias: Optional[str]) -> QuerySet: ... def using(self, alias: Optional[str]) -> QuerySet: ...
@property @property
def ordered(self) -> bool: ... def ordered(self) -> bool: ...
@property @property
def db(self) -> str: ... def db(self) -> str: ...
def resolve_expression(self, *args: Any, **kwargs: Any) -> Query: ... def resolve_expression(self, *args: Any, **kwargs: Any) -> Query: ...
class InstanceCheckMeta(type): class InstanceCheckMeta(type):
def __instancecheck__(self, instance: Union[QuerySet, str]) -> bool: ... def __instancecheck__(self, instance: Union[QuerySet, str]) -> bool: ...
class EmptyQuerySet: class EmptyQuerySet:
def __init__(self, *args: Any, **kwargs: Any) -> Any: ... def __init__(self, *args: Any, **kwargs: Any) -> Any: ...
class RawQuerySet: class RawQuerySet:
columns: List[str] columns: List[str]
model_fields: Dict[str, django.db.models.fields.Field] model_fields: Dict[str, django.db.models.fields.Field]
@@ -236,80 +307,108 @@ class RawQuerySet:
Tuple, Tuple,
] = ... ] = ...
translations: Dict[str, str] = ... translations: Dict[str, str] = ...
def __init__( def __init__(
self, self,
raw_query: str, raw_query: str,
model: Optional[Type[Model]] = ..., model: Optional[Type[Model]] = ...,
query: Optional[RawQuery] = ..., query: Optional[RawQuery] = ...,
params: Optional[ params: Optional[
Union[ Union[
Dict[str, str], Dict[str, str],
List[datetime], List[datetime],
List[Decimal], List[Decimal],
List[str], List[str],
Set[str], Set[str],
Tuple, Tuple,
] ]
] = ..., ] = ...,
translations: Optional[Dict[str, str]] = ..., translations: Optional[Dict[str, str]] = ...,
using: Optional[str] = ..., using: Optional[str] = ...,
hints: Optional[Dict[Any, Any]] = ..., hints: Optional[Dict[Any, Any]] = ...,
) -> None: ... ) -> None: ...
def resolve_model_init_order( def resolve_model_init_order(
self self
) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ... ) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ...
def prefetch_related(self, *lookups: Any) -> RawQuerySet: ... def prefetch_related(self, *lookups: Any) -> RawQuerySet: ...
def __len__(self) -> int: ... def __len__(self) -> int: ...
def __bool__(self) -> bool: ... def __bool__(self) -> bool: ...
def __iter__(self) -> Any: ... def __iter__(self) -> Any: ...
def iterator(self) -> Iterator[Model]: ... def iterator(self) -> Iterator[Model]: ...
def __getitem__( def __getitem__(
self, k: Union[int, slice, str] self, k: Union[int, slice, str]
) -> Union[List[Model], Model]: ... ) -> Union[List[Model], Model]: ...
@property @property
def db(self) -> str: ... def db(self) -> str: ...
def using(self, alias: Any): ... def using(self, alias: Any): ...
def columns(self) -> List[str]: ... def columns(self) -> List[str]: ...
def model_fields(self) -> Dict[str, Field]: ... def model_fields(self) -> Dict[str, Field]: ...
class Prefetch: class Prefetch:
prefetch_through: str = ... prefetch_through: str = ...
prefetch_to: str = ... prefetch_to: str = ...
queryset: Optional[django.db.models.query.QuerySet] = ... queryset: Optional[django.db.models.query.QuerySet] = ...
to_attr: Optional[str] = ... to_attr: Optional[str] = ...
def __init__( def __init__(
self, self,
lookup: str, lookup: str,
queryset: Optional[QuerySet] = ..., queryset: Optional[QuerySet] = ...,
to_attr: Optional[str] = ..., to_attr: Optional[str] = ...,
) -> None: ... ) -> None: ...
def add_prefix(self, prefix: str) -> None: ... def add_prefix(self, prefix: str) -> None: ...
def get_current_prefetch_to(self, level: int) -> str: ... def get_current_prefetch_to(self, level: int) -> str: ...
def get_current_to_attr(self, level: int) -> Tuple[str, Optional[bool]]: ... def get_current_to_attr(self, level: int) -> Tuple[str, Optional[bool]]: ...
def get_current_queryset(self, level: int) -> Optional[QuerySet]: ... def get_current_queryset(self, level: int) -> Optional[QuerySet]: ...
def __eq__(self, other: None) -> bool: ... def __eq__(self, other: None) -> bool: ...
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
def normalize_prefetch_lookups( def normalize_prefetch_lookups(
lookups: reversed, prefix: None = ... lookups: reversed, prefix: None = ...
) -> List[Prefetch]: ... ) -> List[Prefetch]: ...
def prefetch_related_objects( def prefetch_related_objects(
model_instances: Union[List[Model], List[UUID]], *related_lookups: Any model_instances: Union[List[Model], List[UUID]], *related_lookups: Any
) -> None: ... ) -> None: ...
def get_prefetcher( def get_prefetcher(
instance: Model, through_attr: str, to_attr: str instance: Model, through_attr: str, to_attr: str
) -> Tuple[ ) -> Tuple[
GenericForeignKey, Union[GenericForeignKey, property], bool, bool GenericForeignKey, Union[GenericForeignKey, property], bool, bool
]: ... ]: ...
def prefetch_one_level( def prefetch_one_level(
instances: List[Model], instances: List[Model],
prefetcher: Union[ prefetcher: Union[
GenericForeignKey, ForwardManyToOneDescriptor, ReverseOneToOneDescriptor GenericForeignKey, ForwardManyToOneDescriptor, ReverseOneToOneDescriptor
], ],
lookup: Prefetch, lookup: Prefetch,
level: int, level: int,
) -> Tuple[List[Model], List[Prefetch]]: ... ) -> Tuple[List[Model], List[Prefetch]]: ...
class RelatedPopulator: class RelatedPopulator:
db: str = ... db: str = ...
cols_start: int = ... cols_start: int = ...
@@ -321,186 +420,27 @@ class RelatedPopulator:
related_populators: List[django.db.models.query.RelatedPopulator] = ... related_populators: List[django.db.models.query.RelatedPopulator] = ...
local_setter: Callable = ... local_setter: Callable = ...
remote_setter: Callable = ... remote_setter: Callable = ...
def __init__( def __init__(
self, self,
klass_info: Dict[ klass_info: Dict[str, Any],
str, select: List[Tuple[Expression, Tuple[str, List[int]], Optional[str]]],
Union[ db: str,
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
FieldCacheMixin,
],
],
select: List[Tuple[Expression, Tuple[str, List[int]], Optional[str]]],
db: str,
) -> None: ...
def populate(
self,
row: Union[
List[Optional[Union[date, int, str]]],
List[Union[date, Decimal, float, str]],
Tuple[Union[int, str], str, int],
],
from_obj: Model,
) -> None: ... ) -> None: ...
def get_related_populators( def populate(
klass_info: Dict[ self,
str, row: Union[
Union[ List[Optional[Union[date, int, str]]],
Callable, List[Union[date, Decimal, float, str]],
List[ Tuple[Union[int, str], str, int],
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
int
],
Type[
Model
],
bool,
ForeignKey,
],
]
],
List[
int
],
Type[
Model
],
bool,
ForeignKey,
],
]
],
List[
int
],
Type[
Model
],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
FieldCacheMixin,
],
]
], ],
List[int], from_obj: Model,
Type[Model], ) -> None: ...
bool,
FieldCacheMixin,
], def get_related_populators(
], klass_info: Dict[str, Any],
select: List[Tuple[Expression, Tuple[str, List[bool]], Optional[str]]], select: List[Tuple[Expression, Tuple[str, List[bool]], Optional[str]]],
db: str, db: str,
) -> List[RelatedPopulator]: ... ) -> List[RelatedPopulator]: ...

View File

@@ -5,15 +5,12 @@ from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union) Type, Union)
from uuid import UUID from uuid import UUID
from django.contrib.contenttypes.models import ContentType
from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.backends.utils import CursorWrapper from django.db.backends.utils import CursorWrapper
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.expressions import (BaseExpression, Col, Expression, from django.db.models.expressions import (BaseExpression, Col, Expression,
OrderBy, RawSQL, SQLiteNumericMixin) OrderBy, RawSQL, SQLiteNumericMixin)
from django.db.models.fields import DateTimeCheckMixin, Field from django.db.models.fields import DateTimeCheckMixin, Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignKey
from django.db.models.functions.text import Lower from django.db.models.functions.text import Lower
from django.db.models.options import Options from django.db.models.options import Options
from django.db.models.sql.query import Query, RawQuery from django.db.models.sql.query import Query, RawQuery
@@ -21,6 +18,7 @@ from django.utils.datastructures import ImmutableList
FORCE: Any FORCE: Any
class SQLCompiler: class SQLCompiler:
query: Any = ... query: Any = ...
connection: Any = ... connection: Any = ...
@@ -30,17 +28,22 @@ class SQLCompiler:
annotation_col_map: Any = ... annotation_col_map: Any = ...
klass_info: Any = ... klass_info: Any = ...
ordering_parts: Any = ... ordering_parts: Any = ...
def __init__( def __init__(
self, self,
query: Union[Query, RawQuery], query: Union[Query, RawQuery],
connection: DatabaseWrapper, connection: DatabaseWrapper,
using: Optional[str], using: Optional[str],
) -> None: ... ) -> None: ...
col_count: Any = ... col_count: Any = ...
def setup_query(self) -> None: ... def setup_query(self) -> None: ...
has_extra_select: Any = ... has_extra_select: Any = ...
def pre_sql_setup( def pre_sql_setup(
self self
) -> Tuple[ ) -> Tuple[
List[ List[
Tuple[OrderBy, Tuple[str, Union[List[Any], Tuple[str, str]]], None] Tuple[OrderBy, Tuple[str, Union[List[Any], Tuple[str, str]]], None]
@@ -48,24 +51,27 @@ class SQLCompiler:
List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]], List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]],
List[Tuple[str, List[float]]], List[Tuple[str, List[float]]],
]: ... ]: ...
def get_group_by( def get_group_by(
self, self,
select: List[ select: List[
Tuple[ Tuple[
Union[BaseExpression, SQLiteNumericMixin], Union[BaseExpression, SQLiteNumericMixin],
Tuple[str, List[float]], Tuple[str, List[float]],
Optional[str], Optional[str],
] ]
], ],
order_by: List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]], order_by: List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]],
) -> List[Tuple[str, List[float]]]: ... ) -> List[Tuple[str, List[float]]]: ...
def collapse_group_by( def collapse_group_by(
self, self,
expressions: List[Expression], expressions: List[Expression],
having: Union[List[Expression], Tuple], having: Union[List[Expression], Tuple],
) -> List[Expression]: ... ) -> List[Expression]: ...
def get_select( def get_select(
self self
) -> Tuple[ ) -> Tuple[
List[ List[
Tuple[ Tuple[
@@ -75,153 +81,91 @@ class SQLCompiler:
] ]
], ],
Optional[ Optional[
Dict[ Dict[str, Any]
str,
Union[
List[
Dict[
str,
Union[
Callable,
List[int],
Type[ContentType],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
],
]
], ],
Dict[str, int], Dict[str, int],
]: ... ]: ...
def get_order_by( def get_order_by(
self self
) -> List[Tuple[OrderBy, Tuple[str, List[Any], bool]]]: ... ) -> List[Tuple[OrderBy, Tuple[str, List[Any], bool]]]: ...
def get_extra_select( def get_extra_select(
self, self,
order_by: List[Tuple[OrderBy, Tuple[str, List[Any], bool]]], order_by: List[Tuple[OrderBy, Tuple[str, List[Any], bool]]],
select: List[ select: List[
Tuple[ Tuple[
Union[Expression, SQLiteNumericMixin], Union[Expression, SQLiteNumericMixin],
Tuple[str, List[float]], Tuple[str, List[float]],
Optional[str], Optional[str],
] ]
],
) -> List[Tuple[OrderBy, Tuple[str, List[Any]], None]]: ...
def quote_name_unless_alias(self, name: str) -> str: ...
def compile(
self, node: Any, select_format: Any = ...
) -> Tuple[str, Union[List[Optional[int]], Tuple[int, int]]]: ...
def get_combinator_sql(
self, combinator: str, all: bool
) -> Tuple[List[str], Union[List[int], List[str]]]: ...
def as_sql(
self, with_limits: bool = ..., with_col_aliases: bool = ...
) -> Any: ...
def get_default_columns(
self,
start_alias: Optional[str] = ...,
opts: Optional[Options] = ...,
from_parent: Optional[Type[Model]] = ...,
) -> List[Col]: ...
def get_distinct(self) -> Tuple[List[Any], List[Any]]: ...
def find_ordering_name(
self,
name: str,
opts: Options,
alias: Optional[str] = ...,
default_order: str = ...,
already_seen: Optional[
Set[Tuple[Optional[Tuple[Tuple[str, str]]], Tuple[Tuple[str, str]]]]
] = ...,
) -> List[Tuple[OrderBy, bool]]: ...
def get_from_clause(self) -> Tuple[List[str], List[Union[int, str]]]: ...
def get_related_selections(
self,
select: List[Tuple[Expression, Optional[str]]],
opts: Optional[Options] = ...,
root_alias: Optional[str] = ...,
cur_depth: int = ...,
requested: Optional[
Union[Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]], bool]
] = ...,
restricted: Optional[bool] = ...,
) -> List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[
Dict[
str,
Union[
Callable,
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
ForeignKey,
],
]
],
List[int],
Type[Model],
bool,
FieldCacheMixin,
], ],
] ) -> List[Tuple[OrderBy, Tuple[str, List[Any]], None]]: ...
]: ...
def quote_name_unless_alias(self, name: str) -> str: ...
def compile(
self, node: Any, select_format: Any = ...
) -> Tuple[str, Union[List[Optional[int]], Tuple[int, int]]]: ...
def get_combinator_sql(
self, combinator: str, all: bool
) -> Tuple[List[str], Union[List[int], List[str]]]: ...
def as_sql(
self, with_limits: bool = ..., with_col_aliases: bool = ...
) -> Any: ...
def get_default_columns(
self,
start_alias: Optional[str] = ...,
opts: Optional[Options] = ...,
from_parent: Optional[Type[Model]] = ...,
) -> List[Col]: ...
def get_distinct(self) -> Tuple[List[Any], List[Any]]: ...
def find_ordering_name(
self,
name: str,
opts: Options,
alias: Optional[str] = ...,
default_order: str = ...,
already_seen: Optional[
Set[Tuple[Optional[Tuple[Tuple[str, str]]], Tuple[Tuple[str, str]]]]
] = ...,
) -> List[Tuple[OrderBy, bool]]: ...
def get_from_clause(self) -> Tuple[List[str], List[Union[int, str]]]: ...
def get_related_selections(
self,
select: List[Tuple[Expression, Optional[str]]],
opts: Optional[Options] = ...,
root_alias: Optional[str] = ...,
cur_depth: int = ...,
requested: Optional[
Union[Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]], bool]
] = ...,
restricted: Optional[bool] = ...,
) -> List[Dict[str, Any]]: ...
def get_select_for_update_of_arguments(self): ... def get_select_for_update_of_arguments(self): ...
def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ... def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ...
def get_converters( def get_converters(
self, expressions: Union[List[RawSQL], List[SQLiteNumericMixin]] self, expressions: Union[List[RawSQL], List[SQLiteNumericMixin]]
) -> Dict[ ) -> Dict[
int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]] int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]]
]: ... ]: ...
def apply_converters( def apply_converters(
self, self,
rows: chain, rows: chain,
converters: Dict[ converters: Dict[
int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]] int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]]
], ],
) -> Iterator[ ) -> Iterator[
Union[ Union[
List[Optional[Union[bytes, datetime, int, str]]], List[Optional[Union[bytes, datetime, int, str]]],
@@ -229,63 +173,82 @@ class SQLCompiler:
List[Optional[Union[datetime, float, str, UUID]]], List[Optional[Union[datetime, float, str, UUID]]],
] ]
]: ... ]: ...
def results_iter( def results_iter(
self, self,
results: Optional[ results: Optional[
Union[Iterator[Any], List[List[Tuple[Union[int, str]]]]] Union[Iterator[Any], List[List[Tuple[Union[int, str]]]]]
] = ..., ] = ...,
tuple_expected: bool = ..., tuple_expected: bool = ...,
chunked_fetch: bool = ..., chunked_fetch: bool = ...,
chunk_size: int = ..., chunk_size: int = ...,
) -> Union[Iterator[Any], chain, map]: ... ) -> Union[Iterator[Any], chain, map]: ...
def has_results(self) -> bool: ... def has_results(self) -> bool: ...
def execute_sql( def execute_sql(
self, self,
result_type: str = ..., result_type: str = ...,
chunked_fetch: bool = ..., chunked_fetch: bool = ...,
chunk_size: int = ..., chunk_size: int = ...,
) -> Optional[Union[Iterator[Any], CursorWrapper]]: ... ) -> Optional[Union[Iterator[Any], CursorWrapper]]: ...
def as_subquery_condition( def as_subquery_condition(
self, alias: str, columns: List[str], compiler: SQLCompiler self, alias: str, columns: List[str], compiler: SQLCompiler
) -> Tuple[str, Tuple]: ... ) -> Tuple[str, Tuple]: ...
def explain_query(self) -> Iterator[str]: ... def explain_query(self) -> Iterator[str]: ...
class SQLInsertCompiler(SQLCompiler): class SQLInsertCompiler(SQLCompiler):
return_id: bool = ... return_id: bool = ...
def field_as_sql( def field_as_sql(
self, field: Optional[Field], val: Optional[Union[Lower, float, str]] self, field: Optional[Field], val: Optional[Union[Lower, float, str]]
) -> Tuple[str, Union[List[int], List[str]]]: ... ) -> Tuple[str, Union[List[int], List[str]]]: ...
def prepare_value( def prepare_value(
self, field: Field, value: Any self, field: Field, value: Any
) -> Optional[Union[Lower, float, str]]: ... ) -> Optional[Union[Lower, float, str]]: ...
def pre_save_val(self, field: Field, obj: Model) -> Any: ... def pre_save_val(self, field: Field, obj: Model) -> Any: ...
def assemble_as_sql( def assemble_as_sql(
self, self,
fields: Union[ fields: Union[
List[None], List[DateTimeCheckMixin], List[Field], ImmutableList List[None], List[DateTimeCheckMixin], List[Field], ImmutableList
], ],
value_rows: Union[ value_rows: Union[
List[List[Optional[Union[Lower, int]]]], List[List[Union[int, str]]] List[List[Optional[Union[Lower, int]]]], List[List[Union[int, str]]]
], ],
) -> Tuple[Tuple[Tuple[str]], List[List[Optional[Union[int, str]]]]]: ... ) -> Tuple[Tuple[Tuple[str]], List[List[Optional[Union[int, str]]]]]: ...
def as_sql(self) -> List[Tuple[str, Tuple[Union[float, str]]]]: ... def as_sql(self) -> List[Tuple[str, Tuple[Union[float, str]]]]: ...
def execute_sql(self, return_id: Optional[bool] = ...) -> Any: ... def execute_sql(self, return_id: Optional[bool] = ...) -> Any: ...
class SQLDeleteCompiler(SQLCompiler): class SQLDeleteCompiler(SQLCompiler):
def as_sql(self) -> Tuple[str, Tuple]: ... def as_sql(self) -> Tuple[str, Tuple]: ...
class SQLUpdateCompiler(SQLCompiler): class SQLUpdateCompiler(SQLCompiler):
def as_sql(self) -> Tuple[str, Tuple]: ... def as_sql(self) -> Tuple[str, Tuple]: ...
def execute_sql(self, result_type: str) -> int: ... def execute_sql(self, result_type: str) -> int: ...
def pre_sql_setup(self) -> None: ... def pre_sql_setup(self) -> None: ...
class SQLAggregateCompiler(SQLCompiler): class SQLAggregateCompiler(SQLCompiler):
col_count: Any = ... col_count: Any = ...
def as_sql(self) -> Tuple[str, Tuple]: ... def as_sql(self) -> Tuple[str, Tuple]: ...
def cursor_iter( def cursor_iter(
cursor: CursorWrapper, cursor: CursorWrapper,
sentinel: List[Any], sentinel: List[Any],
col_count: Optional[int], col_count: Optional[int],
itersize: int, itersize: int,
) -> Iterator[List[Tuple[Union[date, int]]]]: ... ) -> Iterator[List[Tuple[Union[date, int]]]]: ...