fix tests

This commit is contained in:
Maxim Kurnikov
2018-12-22 20:58:19 +03:00
parent c252cba2bb
commit 45c186c97b
3 changed files with 13 additions and 118 deletions

View File

@@ -153,7 +153,7 @@ class Func(SQLiteNumericMixin, Expression):
template: str = ...
arg_joiner: str = ...
arity: Any = ...
source_expressions: Any = ...
source_expressions: List[Expression] = ...
extra: Any = ...
def __init__(self, *expressions: Any, output_field: Optional[Any] = ..., **extra: Any) -> None: ...
def get_source_expressions(self) -> List[Combinable]: ...

View File

@@ -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.models import Func, Transform
from django.db.models.expressions import Combinable, Expression, Value
from django.db.models.sql.compiler import SQLCompiler
from django.db.models import Func, Transform
from django.db.models.fields import Field
class BytesToCharFieldConversionMixin:
def convert_value(
self, value: str, expression: BytesToCharFieldConversionMixin, connection: DatabaseWrapper
@@ -12,50 +14,21 @@ class BytesToCharFieldConversionMixin:
class Chr(Transform):
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 = ...
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):
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: ...
class Concat(Func):
contains_aggregate: bool
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):
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 = ...
arity: int = ...
output_field: Field
def __init__(self, expression: str, length: Union[Value, int], **extra: Any) -> None: ...
def get_substr(self) -> Substr: ...
def use_substr(
@@ -67,68 +40,35 @@ class Left(Func):
class Length(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
output_field: Any = ...
def as_mysql(self, compiler: Any, connection: Any): ...
class Lower(Transform):
contains_aggregate: bool
contains_column_references: bool
contains_over_clause: bool
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 = ...
class LPad(BytesToCharFieldConversionMixin, Func):
contains_aggregate: 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 __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
class LTrim(Transform):
contains_aggregate: 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 = ...
lookup_name: str = ...
class Ord(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
output_field: 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):
contains_aggregate: 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 __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
@@ -136,51 +76,22 @@ class Replace(Func):
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 = ...
output_field: Field
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...
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 Right(Left): ...
class RPad(LPad):
contains_aggregate: 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 = ...
output_field: Field
class RTrim(Transform):
contains_aggregate: 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 = ...
lookup_name: str = ...
class StrIndex(Func):
contains_aggregate: bool
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 = ...
def as_postgresql(self, compiler: Any, connection: Any): ...
@@ -188,11 +99,7 @@ class Substr(Func):
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 = ...
output_field: Field
def __init__(
self,
expression: Union[Expression, str],
@@ -200,26 +107,14 @@ class Substr(Func):
length: Optional[Union[Value, int]] = ...,
**extra: Any
) -> 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):
contains_aggregate: 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 = ...
lookup_name: str = ...
class Upper(Transform):
contains_aggregate: bool
contains_over_clause: bool
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 = ...

View File

@@ -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.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.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.utils.datastructures import OrderedSet
from django.utils.safestring import SafeText
from django.db.models import expressions, lookups
from django.db.models.fields import TextField, related_lookups
from django.db.models import lookups
from django.db.models.fields import TextField, related_lookups, Field
class Lookup:
lookup_name: Any = ...
@@ -50,6 +49,7 @@ class Lookup:
class Transform(RegisterLookupMixin, Func):
bilateral: bool = ...
arity: int = ...
output_field: Field
@property
def lhs(self) -> Expression: ...
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...