mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-08 21:14:49 +08:00
fix tests
This commit is contained in:
@@ -153,7 +153,7 @@ class Func(SQLiteNumericMixin, Expression):
|
|||||||
template: str = ...
|
template: str = ...
|
||||||
arg_joiner: str = ...
|
arg_joiner: str = ...
|
||||||
arity: Any = ...
|
arity: Any = ...
|
||||||
source_expressions: Any = ...
|
source_expressions: List[Expression] = ...
|
||||||
extra: Any = ...
|
extra: Any = ...
|
||||||
def __init__(self, *expressions: Any, output_field: Optional[Any] = ..., **extra: Any) -> None: ...
|
def __init__(self, *expressions: Any, output_field: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||||
def get_source_expressions(self) -> List[Combinable]: ...
|
def get_source_expressions(self) -> List[Combinable]: ...
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from typing import Any, List, Optional, Tuple, Union, Dict, Callable
|
from typing import Any, List, Optional, Tuple, Union, Callable
|
||||||
|
|
||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
from django.db.models import Func, Transform
|
|
||||||
from django.db.models.expressions import Combinable, Expression, Value
|
from django.db.models.expressions import Combinable, Expression, Value
|
||||||
from django.db.models.sql.compiler import SQLCompiler
|
from django.db.models.sql.compiler import SQLCompiler
|
||||||
|
|
||||||
|
from django.db.models import Func, Transform
|
||||||
|
from django.db.models.fields import Field
|
||||||
|
|
||||||
class BytesToCharFieldConversionMixin:
|
class BytesToCharFieldConversionMixin:
|
||||||
def convert_value(
|
def convert_value(
|
||||||
self, value: str, expression: BytesToCharFieldConversionMixin, connection: DatabaseWrapper
|
self, value: str, expression: BytesToCharFieldConversionMixin, connection: DatabaseWrapper
|
||||||
@@ -12,50 +14,21 @@ class BytesToCharFieldConversionMixin:
|
|||||||
|
|
||||||
class Chr(Transform):
|
class Chr(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.IntegerField
|
|
||||||
source_expressions: List[django.db.models.expressions.Expression]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
def as_mysql(self, compiler: Any, connection: Any): ...
|
|
||||||
def as_oracle(self, compiler: Any, connection: Any): ...
|
|
||||||
def as_sqlite(
|
|
||||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context: Any
|
|
||||||
) -> Tuple[str, List[int]]: ...
|
|
||||||
|
|
||||||
class ConcatPair(Func):
|
class ConcatPair(Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def as_sqlite(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[str]]: ...
|
|
||||||
def as_mysql(self, compiler: Any, connection: Any): ...
|
|
||||||
def coalesce(self) -> ConcatPair: ...
|
def coalesce(self) -> ConcatPair: ...
|
||||||
|
|
||||||
class Concat(Func):
|
class Concat(Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: Field
|
|
||||||
source_expressions: List[django.db.models.functions.text.ConcatPair]
|
|
||||||
function: Any = ...
|
|
||||||
template: str = ...
|
|
||||||
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
|
|
||||||
|
|
||||||
class Left(Func):
|
class Left(Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
contains_over_clause: bool
|
contains_over_clause: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
output_field: Field
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
arity: int = ...
|
|
||||||
def __init__(self, expression: str, length: Union[Value, int], **extra: Any) -> None: ...
|
def __init__(self, expression: str, length: Union[Value, int], **extra: Any) -> None: ...
|
||||||
def get_substr(self) -> Substr: ...
|
def get_substr(self) -> Substr: ...
|
||||||
def use_substr(
|
def use_substr(
|
||||||
@@ -67,68 +40,35 @@ class Left(Func):
|
|||||||
class Length(Transform):
|
class Length(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
output_field: Any = ...
|
|
||||||
def as_mysql(self, compiler: Any, connection: Any): ...
|
|
||||||
|
|
||||||
class Lower(Transform):
|
class Lower(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
contains_column_references: bool
|
contains_column_references: bool
|
||||||
contains_over_clause: bool
|
contains_over_clause: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: Field
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
|
|
||||||
class LPad(BytesToCharFieldConversionMixin, Func):
|
class LPad(BytesToCharFieldConversionMixin, Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
|
def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
class LTrim(Transform):
|
class LTrim(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
|
|
||||||
class Ord(Transform):
|
class Ord(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
output_field: Any = ...
|
|
||||||
def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
def as_sqlite(
|
|
||||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context: Any
|
|
||||||
) -> Tuple[str, List[Any]]: ...
|
|
||||||
|
|
||||||
class Repeat(BytesToCharFieldConversionMixin, Func):
|
class Repeat(BytesToCharFieldConversionMixin, Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
output_field: django.db.models.fields.CharField
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
|
def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
|
||||||
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
@@ -136,51 +76,22 @@ class Replace(Func):
|
|||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
contains_over_clause: bool
|
contains_over_clause: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
output_field: Field
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...
|
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
class Right(Left):
|
class Right(Left): ...
|
||||||
contains_aggregate: bool
|
|
||||||
contains_over_clause: bool
|
|
||||||
convert_value: Callable
|
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def get_substr(self) -> Substr: ...
|
|
||||||
|
|
||||||
class RPad(LPad):
|
class RPad(LPad):
|
||||||
contains_aggregate: bool
|
output_field: Field
|
||||||
convert_value: Callable
|
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
|
|
||||||
class RTrim(Transform):
|
class RTrim(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
|
|
||||||
class StrIndex(Func):
|
class StrIndex(Func):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
arity: int = ...
|
|
||||||
output_field: Any = ...
|
output_field: Any = ...
|
||||||
def as_postgresql(self, compiler: Any, connection: Any): ...
|
def as_postgresql(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
@@ -188,11 +99,7 @@ class Substr(Func):
|
|||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
contains_over_clause: bool
|
contains_over_clause: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
output_field: Field
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
expression: Union[Expression, str],
|
expression: Union[Expression, str],
|
||||||
@@ -200,26 +107,14 @@ class Substr(Func):
|
|||||||
length: Optional[Union[Value, int]] = ...,
|
length: Optional[Union[Value, int]] = ...,
|
||||||
**extra: Any
|
**extra: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def as_sqlite(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[Union[int, str]]]: ...
|
|
||||||
def as_oracle(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[int]]: ...
|
|
||||||
|
|
||||||
class Trim(Transform):
|
class Trim(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: django.db.models.fields.CharField
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
|
|
||||||
class Upper(Transform):
|
class Upper(Transform):
|
||||||
contains_aggregate: bool
|
contains_aggregate: bool
|
||||||
contains_over_clause: bool
|
contains_over_clause: bool
|
||||||
convert_value: Callable
|
convert_value: Callable
|
||||||
extra: Dict[Any, Any]
|
|
||||||
is_summary: bool
|
|
||||||
output_field: Field
|
|
||||||
source_expressions: List[django.db.models.expressions.Combinable]
|
|
||||||
function: str = ...
|
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
|
|||||||
@@ -4,15 +4,14 @@ from typing import Any, Dict, List, Optional, Tuple, Type, Union, Iterable
|
|||||||
|
|
||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
from django.db.models.expressions import Combinable, Expression, Func
|
from django.db.models.expressions import Combinable, Expression, Func
|
||||||
from django.db.models.functions.datetime import ExtractYear
|
|
||||||
from django.db.models.query_utils import RegisterLookupMixin
|
from django.db.models.query_utils import RegisterLookupMixin
|
||||||
from django.db.models.sql.compiler import SQLCompiler
|
from django.db.models.sql.compiler import SQLCompiler
|
||||||
from django.db.models.sql.query import Query
|
from django.db.models.sql.query import Query
|
||||||
from django.utils.datastructures import OrderedSet
|
from django.utils.datastructures import OrderedSet
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
|
|
||||||
from django.db.models import expressions, lookups
|
from django.db.models import lookups
|
||||||
from django.db.models.fields import TextField, related_lookups
|
from django.db.models.fields import TextField, related_lookups, Field
|
||||||
|
|
||||||
class Lookup:
|
class Lookup:
|
||||||
lookup_name: Any = ...
|
lookup_name: Any = ...
|
||||||
@@ -50,6 +49,7 @@ class Lookup:
|
|||||||
class Transform(RegisterLookupMixin, Func):
|
class Transform(RegisterLookupMixin, Func):
|
||||||
bilateral: bool = ...
|
bilateral: bool = ...
|
||||||
arity: int = ...
|
arity: int = ...
|
||||||
|
output_field: Field
|
||||||
@property
|
@property
|
||||||
def lhs(self) -> Expression: ...
|
def lhs(self) -> Expression: ...
|
||||||
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
|
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user