Skip to content

Commit ffd0b8c

Browse files
authored
Update some database backend attributes for Django 5.1 (#2567)
From django/django@b863c5f: * `django.db.backends.base.operations.BaseDatabaseOperations.force_group_by` added From django/django@db349fc: * `django.db.backends.ddl_references.Reference.references_index` added * `django.db.backends.ddl_references.Statement.references_index` added * `django.db.backends.ddl_references.Table.references_index` added From django/django@6375cee: * `django.db.backends.base.operations.BaseDatabaseOperations.window_frame_end` removed * `django.db.backends.base.operations.BaseDatabaseOperations.window_frame_start` removed * `django.db.backends.base.operations.BaseDatabaseOperations.window_frame_value` added From django/django@912f72a: * `django.db.backends.base.operations.BaseDatabaseOperations.bulk_insert_sql` added * other `bulk_insert_sql` methods removed
1 parent 865b668 commit ffd0b8c

File tree

9 files changed

+10
-18
lines changed

9 files changed

+10
-18
lines changed

django-stubs/contrib/gis/db/backends/mysql/operations.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
2020
@cached_property
2121
def from_text(self) -> str: ... # type: ignore[override]
2222
@cached_property
23+
def collect(self) -> str: ...
24+
@cached_property
2325
def gis_operators(self) -> dict[str, SpatialOperator]: ...
2426
disallowed_aggregates: Any
2527
@cached_property

django-stubs/db/backends/base/operations.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ class BaseDatabaseOperations:
4747
def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any) -> Any: ...
4848
@deprecated("field_cast_sql() is deprecated and will be removed in Django 6.0. Use lookup_cast() instead.")
4949
def field_cast_sql(self, db_type: str | None, internal_type: str) -> str: ...
50+
def force_group_by(self) -> list[str]: ...
5051
def force_no_ordering(self) -> list[Any]: ...
5152
def for_update_sql(
5253
self, nowait: bool = False, skip_locked: bool = False, of: Any = (), no_key: bool = False
5354
) -> str: ...
5455
def limit_offset_sql(self, low_mark: int, high_mark: int | None) -> str: ...
56+
def bulk_insert_sql(self, fields: Iterable[Field], placeholder_rows: Iterable[str]) -> str: ...
5557
def last_executed_query(self, cursor: Any, sql: Any, params: Any) -> str: ...
5658
def last_insert_id(self, cursor: CursorWrapper, table_name: str, pk_name: str) -> int: ...
5759
def lookup_cast(self, lookup_type: str, internal_type: str | None = None) -> str: ...
@@ -105,8 +107,7 @@ class BaseDatabaseOperations:
105107
def modify_insert_params(self, placeholder: str, params: Any) -> Any: ...
106108
def integer_field_range(self, internal_type: Any) -> tuple[int, int]: ...
107109
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> tuple[str, tuple[Any, ...]]: ...
108-
def window_frame_start(self, start: Any) -> str: ...
109-
def window_frame_end(self, end: Any) -> str: ...
110+
def window_frame_value(self, value: int | None) -> str: ...
110111
def window_frame_rows_start_end(self, start: int | None = None, end: int | None = None) -> tuple[str, str]: ...
111112
def window_frame_range_start_end(self, start: int | None = None, end: int | None = None) -> tuple[str, str]: ...
112113
def explain_query_prefix(self, format: str | None = None, **options: Any) -> str: ...

django-stubs/db/backends/ddl_references.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ class _QuoteCallable(Protocol):
1010
class Reference:
1111
def references_table(self, table: Any) -> bool: ...
1212
def references_column(self, table: Any, column: Any) -> bool: ...
13+
def references_index(self, table: Any, index: Any) -> bool: ...
1314
def rename_table_references(self, old_table: Any, new_table: Any) -> None: ...
1415
def rename_column_references(self, table: Any, old_column: Any, new_column: Any) -> None: ...
1516

1617
class Table(Reference):
1718
table: str
1819
quote_name: _QuoteCallable
1920
def __init__(self, table: str, quote_name: _QuoteCallable) -> None: ...
21+
def references_index(self, table: Any, index: Any) -> bool: ...
2022
def references_table(self, table: str) -> bool: ...
2123
def rename_table_references(self, old_table: str, new_table: str) -> None: ...
2224

@@ -81,5 +83,6 @@ class Statement(Reference):
8183
def __init__(self, template: str, **parts: Any) -> None: ...
8284
def references_table(self, table: str) -> bool: ...
8385
def references_column(self, table: str, column: str) -> bool: ...
86+
def references_index(self, table: Any, index: Any) -> bool: ...
8487
def rename_table_references(self, old_table: str, new_table: str) -> None: ...
8588
def rename_column_references(self, table: str, old_column: str, new_column: str) -> None: ...

django-stubs/db/backends/mysql/operations.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class DatabaseOperations(BaseDatabaseOperations):
3030
def adapt_datetimefield_value(self, value: Any) -> Any: ...
3131
def adapt_timefield_value(self, value: Any) -> Any: ...
3232
def max_name_length(self) -> Any: ...
33-
def bulk_insert_sql(self, fields: Any, placeholder_rows: Any) -> Any: ...
3433
def combine_expression(self, connector: Any, sub_expressions: Any) -> Any: ...
3534
def get_db_converters(self, expression: Any) -> Any: ...
3635
def convert_booleanfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...

django-stubs/db/backends/oracle/operations.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class DatabaseOperations(BaseDatabaseOperations):
5353
def adapt_datetimefield_value(self, value: Any) -> Any: ...
5454
def adapt_timefield_value(self, value: Any) -> Any: ...
5555
def combine_expression(self, connector: Any, sub_expressions: Any) -> Any: ...
56-
def bulk_insert_sql(self, fields: Any, placeholder_rows: Any) -> str: ...
5756
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> Any: ...
5857
def bulk_batch_size(self, fields: Any, objs: Any) -> int: ...
5958
def conditional_expression_supported_in_where_clause(self, expression: Any) -> bool: ...
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections.abc import Iterable
21
from typing import Any
32

43
from django.db.backends.base.operations import BaseDatabaseOperations
@@ -8,6 +7,5 @@ class DatabaseOperations(BaseDatabaseOperations):
87
connection: DatabaseWrapper
98
explain_options: frozenset[str]
109

11-
def bulk_insert_sql(self, fields: Any, placeholder_rows: Iterable[str]) -> str: ...
1210
def compose_sql(self, sql: Any, params: Any) -> Any: ...
1311
def fetch_returned_insert_rows(self, cursor: Any) -> Any: ...

django-stubs/db/backends/sqlite3/operations.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from collections.abc import Callable, Iterable
1+
from collections.abc import Callable
22
from typing import Any
33
from uuid import UUID
44

55
from django.db.backends.base.operations import BaseDatabaseOperations
66

77
class DatabaseOperations(BaseDatabaseOperations):
88
jsonfield_datatype_values: frozenset[str]
9-
def bulk_insert_sql(self, fields: Any, placeholder_rows: Iterable[str]) -> str: ...
109
def convert_booleanfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
1110
def convert_datefield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
1211
def convert_datetimefield_value(self, value: Any, expression: Any, connection: Any) -> Any | None: ...

scripts/stubtest/allowlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ django.contrib.contenttypes.fields.ReverseGenericManyToOneDescriptor.related_man
163163
django.contrib.gis.db.backends.base.operations.BaseSpatialOperations.select_extent
164164
django.contrib.gis.db.backends.mysql.features.DatabaseFeatures.django_test_skips
165165
django.contrib.gis.db.backends.mysql.features.DatabaseFeatures.supports_geometry_field_unique_index
166+
django.contrib.gis.db.backends.mysql.operations.MySQLOperations.collect
166167
django.contrib.gis.geoip2.GeoIP2.is_country
167168
django.contrib.gis.geoip2.GeoIP2.is_city
168169
django.contrib.gis.db.backends.mysql.operations.MySQLOperations.from_text

scripts/stubtest/allowlist_todo_django51.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
django.contrib.contenttypes.fields.GenericForeignKey.get_attname_column
77
django.contrib.contenttypes.models.ContentType.get_object_for_this_type
8-
django.contrib.gis.db.backends.mysql.operations.MySQLOperations.collect
98
django.contrib.gis.db.models.ForeignObjectRel.accessor_name
109
django.contrib.gis.forms.ModelChoiceField.validate_no_null_characters
1110
django.contrib.gis.forms.RadioSelect.__slotnames__
@@ -40,14 +39,6 @@ django.contrib.postgres.fields.CIText
4039
django.contrib.postgres.fields.citext.CIText
4140
django.contrib.postgres.indexes.BTreeIndex.__init__
4241
django.core.signing.Signer.__init__
43-
django.db.backends.base.operations.BaseDatabaseOperations.bulk_insert_sql
44-
django.db.backends.base.operations.BaseDatabaseOperations.force_group_by
45-
django.db.backends.base.operations.BaseDatabaseOperations.window_frame_end
46-
django.db.backends.base.operations.BaseDatabaseOperations.window_frame_start
47-
django.db.backends.base.operations.BaseDatabaseOperations.window_frame_value
48-
django.db.backends.ddl_references.Reference.references_index
49-
django.db.backends.ddl_references.Statement.references_index
50-
django.db.backends.ddl_references.Table.references_index
5142
django.db.backends.oracle.features.DatabaseFeatures.bare_select_suffix
5243
django.db.backends.oracle.features.DatabaseFeatures.supports_aggregation_over_interval_types
5344
django.db.backends.oracle.features.DatabaseFeatures.supports_comparing_boolean_expr
@@ -56,7 +47,6 @@ django.db.backends.postgresql.base.DatabaseWrapper.pool
5647
django.db.backends.postgresql.features.DatabaseFeatures.django_test_skips
5748
django.db.backends.postgresql.features.DatabaseFeatures.is_postgresql_16
5849
django.db.backends.sqlite3.base.DatabaseWrapper.transaction_modes
59-
django.db.backends.sqlite3.operations.DatabaseOperations.force_group_by
6050
django.db.migrations.autodetector.MigrationAutodetector.generate_altered_index_together
6151
django.db.migrations.autodetector.OperationDependency
6252
django.db.models.ForeignObjectRel.accessor_name

0 commit comments

Comments
 (0)