This commit is contained in:
Maxim Kurnikov
2018-12-20 22:57:47 +03:00
parent 5135b004bd
commit 610e64b5c2
18 changed files with 602 additions and 128 deletions

View File

View File

@@ -0,0 +1,95 @@
from typing import Any, Callable, Dict, Iterator, List, Optional
from django.db.backends.utils import CursorDebugWrapper, CursorWrapper
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
NO_DB_ALIAS: str
class BaseDatabaseWrapper:
data_types: Any = ...
data_types_suffix: Any = ...
data_type_check_constraints: Any = ...
ops: Any = ...
vendor: str = ...
display_name: str = ...
SchemaEditorClass: Any = ...
client_class: Any = ...
creation_class: Any = ...
features_class: Any = ...
introspection_class: Any = ...
ops_class: Any = ...
validation_class: Any = ...
queries_limit: int = ...
connection: Any = ...
settings_dict: Any = ...
alias: Any = ...
queries_log: Any = ...
force_debug_cursor: bool = ...
autocommit: bool = ...
in_atomic_block: bool = ...
savepoint_state: int = ...
savepoint_ids: Any = ...
commit_on_exit: bool = ...
needs_rollback: bool = ...
close_at: Any = ...
closed_in_transaction: bool = ...
errors_occurred: bool = ...
allow_thread_sharing: Any = ...
run_on_commit: Any = ...
run_commit_hooks_on_set_autocommit_on: bool = ...
execute_wrappers: Any = ...
client: Any = ...
creation: Any = ...
features: Any = ...
introspection: Any = ...
validation: Any = ...
def __init__(
self, settings_dict: Dict[str, Dict[str, str]], alias: str = ..., allow_thread_sharing: bool = ...
) -> None: ...
def ensure_timezone(self) -> bool: ...
def timezone(self): ...
def timezone_name(self): ...
@property
def queries_logged(self) -> bool: ...
@property
def queries(self) -> List[Dict[str, str]]: ...
def get_connection_params(self) -> None: ...
def get_new_connection(self, conn_params: Any) -> None: ...
def init_connection_state(self) -> None: ...
def create_cursor(self, name: Optional[Any] = ...) -> None: ...
def connect(self) -> None: ...
def check_settings(self) -> None: ...
def ensure_connection(self) -> None: ...
def cursor(self) -> CursorWrapper: ...
def commit(self) -> None: ...
def rollback(self) -> None: ...
def close(self) -> None: ...
def savepoint(self) -> str: ...
def savepoint_rollback(self, sid: str) -> None: ...
def savepoint_commit(self, sid: str) -> None: ...
def clean_savepoints(self) -> None: ...
def get_autocommit(self) -> bool: ...
def set_autocommit(self, autocommit: bool, force_begin_transaction_with_broken_autocommit: bool = ...) -> None: ...
def get_rollback(self) -> bool: ...
def set_rollback(self, rollback: bool) -> None: ...
def validate_no_atomic_block(self) -> None: ...
def validate_no_broken_transaction(self) -> None: ...
def constraint_checks_disabled(self) -> Iterator[None]: ...
def disable_constraint_checking(self): ...
def enable_constraint_checking(self) -> None: ...
def check_constraints(self, table_names: Optional[Any] = ...) -> None: ...
def is_usable(self) -> None: ...
def close_if_unusable_or_obsolete(self) -> None: ...
def validate_thread_sharing(self) -> None: ...
def prepare_database(self) -> None: ...
def wrap_database_errors(self) -> Any: ...
def chunked_cursor(self) -> CursorWrapper: ...
def make_debug_cursor(self, cursor: CursorWrapper) -> CursorDebugWrapper: ...
def make_cursor(self, cursor: CursorWrapper) -> CursorWrapper: ...
def temporary_connection(self) -> None: ...
def schema_editor(self, *args: Any, **kwargs: Any) -> BaseDatabaseSchemaEditor: ...
def on_commit(self, func: Callable) -> None: ...
def run_and_clear_commit_hooks(self) -> None: ...
def execute_wrapper(self, wrapper: Callable) -> Iterator[None]: ...
def copy(self, alias: None = ..., allow_thread_sharing: None = ...) -> Any: ...

View File

@@ -0,0 +1,9 @@
from typing import Any, Optional
from django.db.backends.base.base import BaseDatabaseWrapper
class BaseDatabaseClient:
executable_name: Any = ...
connection: Any = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def runshell(self) -> None: ...

View File

@@ -0,0 +1,24 @@
from typing import Any, Dict, Optional, Tuple, Union
from django.db.backends.base.base import BaseDatabaseWrapper
TEST_DATABASE_PREFIX: str
class BaseDatabaseCreation:
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def create_test_db(
self, verbosity: int = ..., autoclobber: bool = ..., serialize: bool = ..., keepdb: bool = ...
) -> str: ...
def set_as_test_mirror(
self, primary_settings_dict: Dict[str, Optional[Union[Dict[str, None], int, str]]]
) -> None: ...
def serialize_db_to_string(self) -> str: ...
def deserialize_db_from_string(self, data: str) -> None: ...
def clone_test_db(self, suffix: Any, verbosity: int = ..., autoclobber: bool = ..., keepdb: bool = ...) -> None: ...
def get_test_db_clone_settings(self, suffix: Any): ...
def destroy_test_db(
self, old_database_name: str = ..., verbosity: int = ..., keepdb: bool = ..., suffix: None = ...
) -> None: ...
def sql_table_creation_suffix(self): ...
def test_db_signature(self) -> Tuple[str, str, str, str]: ...

View File

@@ -0,0 +1,100 @@
from typing import Any, Optional
from django.db.backends.base.base import BaseDatabaseWrapper
class BaseDatabaseFeatures:
gis_enabled: bool = ...
allows_group_by_pk: bool = ...
allows_group_by_selected_pks: bool = ...
empty_fetchmany_value: Any = ...
update_can_self_select: bool = ...
interprets_empty_strings_as_nulls: bool = ...
supports_nullable_unique_constraints: bool = ...
supports_partially_nullable_unique_constraints: bool = ...
can_use_chunked_reads: bool = ...
can_return_id_from_insert: bool = ...
can_return_ids_from_bulk_insert: bool = ...
has_bulk_insert: bool = ...
uses_savepoints: bool = ...
can_release_savepoints: bool = ...
related_fields_match_type: bool = ...
allow_sliced_subqueries_with_in: bool = ...
has_select_for_update: bool = ...
has_select_for_update_nowait: bool = ...
has_select_for_update_skip_locked: bool = ...
has_select_for_update_of: bool = ...
select_for_update_of_column: bool = ...
test_db_allows_multiple_connections: bool = ...
supports_unspecified_pk: bool = ...
supports_forward_references: bool = ...
truncates_names: bool = ...
has_real_datatype: bool = ...
supports_subqueries_in_group_by: bool = ...
has_native_uuid_field: bool = ...
has_native_duration_field: bool = ...
supports_temporal_subtraction: bool = ...
supports_regex_backreferencing: bool = ...
supports_date_lookup_using_string: bool = ...
supports_timezones: bool = ...
has_zoneinfo_database: bool = ...
requires_explicit_null_ordering_when_grouping: bool = ...
nulls_order_largest: bool = ...
max_query_params: Any = ...
allows_auto_pk_0: bool = ...
can_defer_constraint_checks: bool = ...
supports_mixed_date_datetime_comparisons: bool = ...
supports_tablespaces: bool = ...
supports_sequence_reset: bool = ...
can_introspect_default: bool = ...
can_introspect_foreign_keys: bool = ...
can_introspect_autofield: bool = ...
can_introspect_big_integer_field: bool = ...
can_introspect_binary_field: bool = ...
can_introspect_decimal_field: bool = ...
can_introspect_ip_address_field: bool = ...
can_introspect_positive_integer_field: bool = ...
can_introspect_small_integer_field: bool = ...
can_introspect_time_field: bool = ...
introspected_boolean_field_type: str = ...
supports_index_column_ordering: bool = ...
can_distinct_on_fields: bool = ...
autocommits_when_autocommit_is_off: bool = ...
atomic_transactions: bool = ...
can_rollback_ddl: bool = ...
supports_atomic_references_rename: bool = ...
supports_combined_alters: bool = ...
supports_foreign_keys: bool = ...
supports_column_check_constraints: bool = ...
supports_paramstyle_pyformat: bool = ...
requires_literal_defaults: bool = ...
connection_persists_old_columns: bool = ...
closed_cursor_error_class: Any = ...
has_case_insensitive_like: bool = ...
requires_sqlparse_for_splitting: bool = ...
bare_select_suffix: str = ...
implied_column_null: bool = ...
uppercases_column_names: bool = ...
supports_select_for_update_with_limit: bool = ...
greatest_least_ignores_nulls: bool = ...
can_clone_databases: bool = ...
ignores_table_name_case: bool = ...
for_update_after_from: bool = ...
supports_select_union: bool = ...
supports_select_intersection: bool = ...
supports_select_difference: bool = ...
supports_slicing_ordering_in_compound: bool = ...
supports_aggregate_filter_clause: bool = ...
supports_index_on_text_field: bool = ...
supports_over_clause: bool = ...
supports_cast_with_precision: bool = ...
create_test_procedure_without_params_sql: Any = ...
create_test_procedure_with_int_param_sql: Any = ...
supports_callproc_kwargs: bool = ...
db_functions_convert_bytes_to_str: bool = ...
supported_explain_formats: Any = ...
validates_explain_options: bool = ...
connection: Any = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def supports_explaining_query_execution(self) -> bool: ...
def supports_transactions(self): ...
def supports_stddev(self): ...

View File

@@ -0,0 +1,27 @@
from collections import namedtuple
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.utils import CursorWrapper
from django.db.models.base import Model
TableInfo = namedtuple("TableInfo", ["name", "type"])
FieldInfo = namedtuple("FieldInfo", "name type_code display_size internal_size precision scale null_ok default")
class BaseDatabaseIntrospection:
data_types_reverse: Any = ...
connection: Any = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def get_field_type(self, data_type: str, description: FieldInfo) -> Union[Tuple[str, Dict[str, int]], str]: ...
def table_name_converter(self, name: str) -> str: ...
def column_name_converter(self, name: str) -> str: ...
def table_names(self, cursor: Optional[CursorWrapper] = ..., include_views: bool = ...) -> List[str]: ...
def get_table_list(self, cursor: Any) -> None: ...
def django_table_names(self, only_existing: bool = ..., include_views: bool = ...) -> List[str]: ...
def installed_models(self, tables: List[str]) -> Set[Type[Model]]: ...
def sequence_list(self) -> List[Dict[str, str]]: ...
def get_sequences(self, cursor: Any, table_name: Any, table_fields: Any = ...) -> None: ...
def get_key_columns(self, cursor: Any, table_name: Any) -> None: ...
def get_primary_key_column(self, cursor: Any, table_name: Any): ...
def get_constraints(self, cursor: Any, table_name: Any) -> None: ...

View File

@@ -0,0 +1,104 @@
from datetime import date, datetime, timedelta
from decimal import Decimal
from typing import Any, List, Optional, Set, Tuple, Type, Union, Sequence
from django.core.management.color import Style
from django.db import DefaultConnectionProxy
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.backends.utils import CursorWrapper
from django.db.models.base import Model
from django.db.models.expressions import Case, Expression
from django.db.models.fields import Field
from django.db.models.sql.compiler import SQLCompiler
class BaseDatabaseOperations:
compiler_module: str = ...
integer_field_ranges: Any = ...
set_operators: Any = ...
cast_data_types: Any = ...
cast_char_field_without_max_length: Any = ...
PRECEDING: str = ...
FOLLOWING: str = ...
UNBOUNDED_PRECEDING: Any = ...
UNBOUNDED_FOLLOWING: Any = ...
CURRENT_ROW: str = ...
explain_prefix: Any = ...
connection: django.db.DefaultConnectionProxy = ...
def __init__(self, connection: Union[DefaultConnectionProxy, BaseDatabaseWrapper]) -> None: ...
def autoinc_sql(self, table: str, column: str) -> None: ...
def bulk_batch_size(self, fields: Any, objs: Any): ...
def cache_key_culling_sql(self) -> str: ...
def unification_cast_sql(self, output_field: Field) -> str: ...
def date_extract_sql(self, lookup_type: None, field_name: None) -> Any: ...
def date_interval_sql(self, timedelta: None) -> Any: ...
def date_trunc_sql(self, lookup_type: None, field_name: None) -> Any: ...
def datetime_cast_date_sql(self, field_name: None, tzname: None) -> Any: ...
def datetime_cast_time_sql(self, field_name: None, tzname: None) -> Any: ...
def datetime_extract_sql(self, lookup_type: None, field_name: None, tzname: None) -> Any: ...
def datetime_trunc_sql(self, lookup_type: None, field_name: None, tzname: None) -> Any: ...
def time_trunc_sql(self, lookup_type: None, field_name: None) -> Any: ...
def time_extract_sql(self, lookup_type: None, field_name: None) -> Any: ...
def deferrable_sql(self) -> str: ...
def distinct_sql(self, fields: List[str], params: Optional[List[Any]]) -> Tuple[List[str], List[Any]]: ...
def fetch_returned_insert_id(self, cursor: Any): ...
def field_cast_sql(self, db_type: Optional[str], internal_type: str) -> str: ...
def force_no_ordering(self) -> List[Any]: ...
def for_update_sql(self, nowait: bool = ..., skip_locked: bool = ..., of: Any = ...): ...
def limit_offset_sql(self, low_mark: int, high_mark: Optional[int]) -> str: ...
def last_executed_query(self, cursor: Any, sql: Any, params: Any): ...
def last_insert_id(self, cursor: CursorWrapper, table_name: str, pk_name: str) -> int: ...
def lookup_cast(self, lookup_type: str, internal_type: str = ...) -> str: ...
def max_in_list_size(self) -> None: ...
def max_name_length(self) -> None: ...
def no_limit_value(self) -> Any: ...
def pk_default_value(self) -> str: ...
def prepare_sql_script(self, sql: Any): ...
def process_clob(self, value: str) -> str: ...
def return_insert_id(self) -> None: ...
def compiler(self, compiler_name: str) -> Type[SQLCompiler]: ...
def quote_name(self, name: str) -> Any: ...
def random_function_sql(self): ...
def regex_lookup(self, lookup_type: str) -> Any: ...
def savepoint_create_sql(self, sid: str) -> str: ...
def savepoint_commit_sql(self, sid: str) -> str: ...
def savepoint_rollback_sql(self, sid: str) -> str: ...
def set_time_zone_sql(self) -> str: ...
def sql_flush(self, style: None, tables: None, sequences: None, allow_cascade: bool = ...) -> Any: ...
def execute_sql_flush(self, using: str, sql_list: List[str]) -> None: ...
def sequence_reset_by_name_sql(self, style: None, sequences: List[Any]) -> List[Any]: ...
def sequence_reset_sql(self, style: Style, model_list: Sequence[Type[Model]]) -> List[Any]: ...
def start_transaction_sql(self) -> str: ...
def end_transaction_sql(self, success: bool = ...) -> str: ...
def tablespace_sql(self, tablespace: Optional[str], inline: bool = ...) -> str: ...
def prep_for_like_query(self, x: str) -> str: ...
prep_for_iexact_query: Any = ...
def validate_autopk_value(self, value: int) -> int: ...
def adapt_unknown_value(self, value: Union[datetime, Decimal, int, str]) -> Union[int, str]: ...
def adapt_datefield_value(self, value: Optional[date]) -> Optional[str]: ...
def adapt_datetimefield_value(self, value: None) -> None: ...
def adapt_timefield_value(self, value: Optional[datetime]) -> Optional[str]: ...
def adapt_decimalfield_value(
self, value: Optional[Decimal], max_digits: Optional[int] = ..., decimal_places: Optional[int] = ...
) -> Optional[str]: ...
def adapt_ipaddressfield_value(self, value: Optional[str]) -> Optional[str]: ...
def year_lookup_bounds_for_date_field(self, value: int) -> List[str]: ...
def year_lookup_bounds_for_datetime_field(self, value: int) -> List[str]: ...
def get_db_converters(self, expression: Expression) -> List[Any]: ...
def convert_durationfield_value(
self, value: Optional[float], expression: Expression, connection: DatabaseWrapper
) -> Optional[timedelta]: ...
def check_expression_support(self, expression: Any) -> None: ...
def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ...
def combine_duration_expression(self, connector: Any, sub_expressions: Any): ...
def binary_placeholder_sql(self, value: Optional[Case]) -> str: ...
def modify_insert_params(
self, placeholder: str, params: Union[List[None], List[bool], List[float], List[str]]
) -> Union[List[None], List[bool], List[float], List[str]]: ...
def integer_field_range(self, internal_type: Any): ...
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any): ...
def window_frame_start(self, start: Any): ...
def window_frame_end(self, end: Any): ...
def window_frame_rows_start_end(self, start: None = ..., end: None = ...) -> Any: ...
def window_frame_range_start_end(self, start: Optional[Any] = ..., end: Optional[Any] = ...): ...
def explain_query_prefix(self, format: Optional[str] = ..., **options: Any) -> str: ...

View File

@@ -0,0 +1,76 @@
from typing import Any, List, Optional, Tuple, Type, Union
from django.db.backends.ddl_references import Statement
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.indexes import Index
logger: Any
class BaseDatabaseSchemaEditor:
sql_create_table: str = ...
sql_rename_table: str = ...
sql_retablespace_table: str = ...
sql_delete_table: str = ...
sql_create_column: str = ...
sql_alter_column: str = ...
sql_alter_column_type: str = ...
sql_alter_column_null: str = ...
sql_alter_column_not_null: str = ...
sql_alter_column_default: str = ...
sql_alter_column_no_default: str = ...
sql_delete_column: str = ...
sql_rename_column: str = ...
sql_update_with_default: str = ...
sql_create_check: str = ...
sql_delete_check: str = ...
sql_create_unique: str = ...
sql_delete_unique: str = ...
sql_create_fk: str = ...
sql_create_inline_fk: Any = ...
sql_delete_fk: str = ...
sql_create_index: str = ...
sql_delete_index: str = ...
sql_create_pk: str = ...
sql_delete_pk: str = ...
sql_delete_procedure: str = ...
connection: Any = ...
collect_sql: Any = ...
collected_sql: Any = ...
atomic_migration: Any = ...
def __init__(self, connection: Any, collect_sql: bool = ..., atomic: bool = ...) -> None: ...
deferred_sql: Any = ...
atomic: Any = ...
def __enter__(self) -> BaseDatabaseSchemaEditor: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def execute(self, sql: Union[Statement, str], params: Optional[Union[List[int], Tuple]] = ...) -> None: ...
def quote_name(self, name: str) -> str: ...
def column_sql(
self, model: Type[Model], field: Field, include_default: bool = ...
) -> Union[Tuple[None, None], Tuple[str, List[Any]]]: ...
def skip_default(self, field: Any): ...
def prepare_default(self, value: Any) -> None: ...
def effective_default(self, field: Field) -> Optional[Union[int, str]]: ...
def quote_value(self, value: Any) -> None: ...
def create_model(self, model: Type[Model]) -> None: ...
def delete_model(self, model: Type[Model]) -> None: ...
def add_index(self, model: Type[Model], index: Index) -> None: ...
def remove_index(self, model: Type[Model], index: Index) -> None: ...
def alter_unique_together(
self,
model: Type[Model],
old_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]],
new_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]],
) -> None: ...
def alter_index_together(
self,
model: Type[Model],
old_index_together: Union[List[List[str]], List[Tuple[str, str]]],
new_index_together: Union[List[List[str]], List[Tuple[str, str]]],
) -> None: ...
def alter_db_table(self, model: Type[Model], old_db_table: str, new_db_table: str) -> None: ...
def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ...
def add_field(self, model: Any, field: Any): ...
def remove_field(self, model: Any, field: Any): ...
def alter_field(self, model: Type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ...
def remove_procedure(self, procedure_name: Any, param_types: Any = ...) -> None: ...

View File

@@ -0,0 +1,10 @@
from typing import Any, List, Optional
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models.fields import Field
class BaseDatabaseValidation:
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def check_field(self, field: Field, **kwargs: Any) -> List[Any]: ...

View File

@@ -0,0 +1,66 @@
from typing import Any, Callable, List, Tuple, Union, Dict
class Reference:
def references_table(self, table: Any): ...
def references_column(self, table: Any, column: Any): ...
def rename_table_references(self, old_table: Any, new_table: Any) -> None: ...
def rename_column_references(self, table: Any, old_column: Any, new_column: Any) -> None: ...
class Table(Reference):
table: str = ...
quote_name: Callable = ...
def __init__(self, table: str, quote_name: Callable) -> None: ...
def references_table(self, table: str) -> bool: ...
def rename_table_references(self, old_table: str, new_table: str) -> None: ...
class TableColumns(Table):
table: str = ...
columns: List[str] = ...
def __init__(self, table: str, columns: List[str]) -> None: ...
def references_column(self, table: str, column: str) -> bool: ...
def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ...
class Columns(TableColumns):
columns: List[str]
table: str
quote_name: Callable = ...
col_suffixes: Tuple = ...
def __init__(
self, table: str, columns: List[str], quote_name: Callable, col_suffixes: Union[List[str], Tuple] = ...
) -> None: ...
class IndexName(TableColumns):
columns: List[str]
table: str
suffix: str = ...
create_index_name: Callable = ...
def __init__(self, table: str, columns: List[str], suffix: str, create_index_name: Callable) -> None: ...
class ForeignKeyName(TableColumns):
columns: List[str]
table: str
to_reference: TableColumns = ...
suffix_template: str = ...
create_fk_name: Callable = ...
def __init__(
self,
from_table: str,
from_columns: List[str],
to_table: str,
to_columns: List[str],
suffix_template: str,
create_fk_name: Callable,
) -> None: ...
def references_table(self, table: str) -> bool: ...
def references_column(self, table: str, column: str) -> bool: ...
def rename_table_references(self, old_table: str, new_table: str) -> None: ...
def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ...
class Statement(Reference):
template: str = ...
parts: Dict[str, Table] = ...
def __init__(self, template: str, **parts: Any) -> None: ...
def references_table(self, table: str) -> bool: ...
def references_column(self, table: str, column: str) -> bool: ...
def rename_table_references(self, old_table: str, new_table: str) -> None: ...
def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ...

View File

@@ -0,0 +1,39 @@
from datetime import date, datetime, time
from decimal import Decimal
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
logger: Any
class CursorWrapper:
cursor: Any = ...
db: Any = ...
def __init__(self, cursor: Any, db: Any) -> None: ...
WRAP_ERROR_ATTRS: Any = ...
def __getattr__(self, attr: str) -> Union[Callable, Tuple[Tuple[str, None, None, None, None, None, None]], int]: ...
def __iter__(self) -> None: ...
def __enter__(self) -> CursorWrapper: ...
def __exit__(self, type: None, value: None, traceback: None) -> None: ...
def callproc(self, procname: str, params: List[Any] = ..., kparams: Dict[str, int] = ...) -> Any: ...
def execute(
self, sql: str, params: Optional[Union[List[bool], List[datetime], List[float], Tuple]] = ...
) -> Optional[Any]: ...
def executemany(
self, sql: str, param_list: Union[Iterator[Any], List[Tuple[Union[int, str]]]]
) -> Optional[Any]: ...
class CursorDebugWrapper(CursorWrapper):
cursor: Any
db: Any
def execute(self, sql: str, params: Optional[Union[List[str], Tuple]] = ...) -> Any: ...
def executemany(self, sql: str, param_list: Iterator[Any]) -> Any: ...
def typecast_date(s: Optional[str]) -> Optional[date]: ...
def typecast_time(s: Optional[str]) -> Optional[time]: ...
def typecast_timestamp(s: Optional[str]) -> Optional[date]: ...
def rev_typecast_decimal(d: Decimal) -> str: ...
def split_identifier(identifier: str) -> Tuple[str, str]: ...
def truncate_name(identifier: str, length: Optional[int] = ..., hash_len: int = ...) -> str: ...
def format_number(
value: Optional[Decimal], max_digits: Optional[int], decimal_places: Optional[int]
) -> Optional[str]: ...
def strip_quotes(table_name: str) -> str: ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Tuple, Type, List
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import ProjectState
class Migration:
@@ -13,14 +13,14 @@ class Migration:
name: str = ...
app_label: str = ...
def __init__(self, name: str, app_label: str) -> None: ...
def __eq__(self, other: Migration) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def mutate_state(self, project_state: ProjectState, preserve: bool = ...) -> ProjectState: ...
def apply(
self, project_state: ProjectState, schema_editor: DatabaseSchemaEditor, collect_sql: bool = ...
self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ...
) -> ProjectState: ...
def unapply(
self, project_state: ProjectState, schema_editor: DatabaseSchemaEditor, collect_sql: bool = ...
self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ...
) -> ProjectState: ...
class SwappableTuple(tuple):

View File

@@ -1,66 +1,28 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.migrations.operations.base import Operation
from django.db.migrations.state import ProjectState
from django.db.models.fields import Field, SlugField
from typing import Any
from django.db.models.fields import Field
from .base import Operation
from .utils import is_referenced_by_foreign_key
class FieldOperation(Operation):
model_name: Any = ...
model_name_lower: str
name: Any = ...
def __init__(self, model_name: str, name: str) -> None: ...
def model_name_lower(self) -> str: ...
def name_lower(self) -> str: ...
def is_same_model_operation(self, operation: FieldOperation) -> bool: ...
def is_same_field_operation(self, operation: AddField) -> bool: ...
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
class AddField(FieldOperation):
field: Any = ...
preserve_default: Any = ...
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[bool, Field, str]]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
class RemoveField(FieldOperation):
model_name: str
model_name_lower: str
name: str
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
class RemoveField(FieldOperation): ...
class AlterField(FieldOperation):
field: Any = ...
preserve_default: Any = ...
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[SlugField, str]]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def describe(self) -> str: ...
def reduce(self, operation: Operation, in_between: List[AlterField], app_label: str = ...) -> bool: ...
class RenameField(FieldOperation):
old_name: Any = ...
@@ -68,10 +30,3 @@ class RenameField(FieldOperation):
def __init__(self, model_name: str, old_name: str, new_name: str) -> None: ...
def old_name_lower(self): ...
def new_name_lower(self) -> str: ...
def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def describe(self): ...
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
def reduce(self, operation: Operation, in_between: List[Any], app_label: str = ...) -> bool: ...

View File

@@ -1,7 +1,6 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from django.contrib.postgres.fields.citext import CIText
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.operations.base import Operation
from django.db.migrations.state import ProjectState
from django.db.models.fields import Field
@@ -24,7 +23,7 @@ class CreateModel(ModelOperation):
def __init__(
self,
name: str,
fields: List[Tuple[str, Union[CIText, Field]]],
fields: List[Tuple[str, Field]],
options: Optional[Dict[str, Any]] = ...,
bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ...,
managers: Optional[List[Tuple[str, Manager]]] = ...,
@@ -32,26 +31,22 @@ class CreateModel(ModelOperation):
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Dict[str, str], List[Tuple[str, Field]], str]]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
def references_model(self, name: str, app_label: str = ...) -> bool: ...
def model_to_key(self, model: str) -> List[str]: ...
def reduce(
self, operation: Operation, in_between: List[Operation], app_label: str = ...
) -> Union[List[CreateModel], bool]: ...
class DeleteModel(ModelOperation):
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
@@ -64,14 +59,12 @@ class RenameModel(ModelOperation):
def deconstruct(self): ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def references_model(self, name: Any, app_label: Optional[Any] = ...): ...
def describe(self): ...
def reduce(self, operation: AlterModelTable, in_between: List[Any], app_label: str = ...) -> bool: ...
class AlterModelTable(ModelOperation):
table: Any = ...
@@ -81,15 +74,11 @@ class AlterModelTable(ModelOperation):
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ...
def describe(self): ...
def reduce(self, operation: Any, in_between: Any, app_label: Optional[Any] = ...): ...
class ModelOptionOperation(ModelOperation):
def reduce(self, operation: Operation, in_between: List[DeleteModel], app_label: str = ...) -> bool: ...
class ModelOptionOperation(ModelOperation): ...
class FieldRelatedOptionOperation(ModelOptionOperation):
def reduce(
self, operation: Operation, in_between: List[Any], app_label: str = ...
) -> Union[List[Operation], bool]: ...
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
class AlterUniqueTogether(FieldRelatedOptionOperation):
option_name: str = ...
@@ -98,34 +87,29 @@ class AlterUniqueTogether(FieldRelatedOptionOperation):
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Set[Tuple[str, str]], str]]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
def describe(self) -> str: ...
class AlterIndexTogether(FieldRelatedOptionOperation):
option_name: str = ...
index_together: Any = ...
def __init__(self, name: str, index_together: Set[Tuple[str, str]]) -> None: ...
def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ...
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
def describe(self): ...
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
name: str
order_with_respect_to: str = ...
def __init__(self, name: str, order_with_respect_to: str) -> None: ...
def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def references_field(self, model_name: str, name: str, app_label: None = ...) -> bool: ...
def describe(self): ...
class AlterModelOptions(ModelOptionOperation):
@@ -154,7 +138,7 @@ class IndexOperation(Operation):
class AddIndex(IndexOperation):
model_name: str = ...
index: django.db.models.indexes.Index = ...
index: Index = ...
def __init__(self, model_name: str, index: Index) -> None: ...
def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Callable, List, Optional
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.operations.models import CreateModel
from django.db.migrations.state import ProjectState, StateApps
@@ -11,15 +11,6 @@ class SeparateDatabaseAndState(Operation):
database_operations: Any = ...
state_operations: Any = ...
def __init__(self, database_operations: List[Any] = ..., state_operations: List[CreateModel] = ...) -> None: ...
def deconstruct(self): ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self): ...
class RunSQL(Operation):
noop: str = ...
@@ -36,13 +27,6 @@ class RunSQL(Operation):
hints: Optional[Any] = ...,
elidable: bool = ...,
) -> None: ...
def deconstruct(self): ...
@property
def reversible(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def describe(self): ...
class RunPython(Operation):
reduces_to_sql: bool = ...
@@ -59,16 +43,5 @@ class RunPython(Operation):
hints: None = ...,
elidable: bool = ...,
) -> None: ...
def deconstruct(self): ...
@property
def reversible(self) -> bool: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self): ...
@staticmethod
def noop(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ...
def noop(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None: ...

View File

@@ -1,14 +1,12 @@
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, DefaultDict
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict
from django.apps.registry import Apps
from django.contrib.postgres.fields.citext import CIText
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.indexes import Index
from django.db.models.manager import Manager
from django.utils.functional import cached_property
from django.db.models.fields import Field
class AppConfigStub:
apps: None
label: str
@@ -25,17 +23,8 @@ class ModelState:
self,
app_label: str,
name: str,
fields: List[Tuple[str, Union[CIText, Field]]],
options: Optional[
Union[
Dict[str, List[Index]],
Dict[str, List[str]],
Dict[str, Set[Tuple[str, str]]],
Dict[str, Tuple[str]],
Dict[str, bool],
Dict[str, str],
]
] = ...,
fields: List[Tuple[str, Field]],
options: Optional[Dict[str, Any]] = ...,
bases: Optional[Tuple[Type[Model]]] = ...,
managers: Optional[List[Tuple[str, Manager]]] = ...,
) -> None: ...
@@ -70,7 +59,6 @@ class ProjectState:
class StateApps(Apps):
all_models: DefaultDict
app_configs: Dict
apps_ready: bool
loading: bool
models_ready: bool

View File

@@ -0,0 +1,24 @@
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.ddl_references import Statement
from django.db.models.base import Model
class Index:
model: Type[Model]
suffix: str = ...
max_name_length: int = ...
fields: List[str] = ...
fields_orders: List[Tuple[str, str]] = ...
name: str = ...
db_tablespace: Optional[str] = ...
def __init__(self, *, fields: Any = ..., name: Optional[Any] = ..., db_tablespace: Optional[Any] = ...) -> None: ...
def check_name(self) -> List[str]: ...
def create_sql(
self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ...
) -> Statement: ...
def remove_sql(self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor) -> str: ...
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, Union[List[str], str]]]: ...
def clone(self) -> Index: ...
def set_name_with_model(self, model: Type[Model]) -> None: ...
def __eq__(self, other: object) -> bool: ...