Skip to content

Commit 563ec60

Browse files
authored
Add window frame exclusion from Django 5.1 (#2554)
1 parent 4e09e51 commit 563ec60

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class BaseDatabaseFeatures:
9999
supports_index_on_text_field: bool
100100
supports_over_clause: bool
101101
supports_frame_range_fixed_distance: bool
102+
supports_frame_exclusion: bool
102103
only_supports_unbounded_with_preceding_and_following: bool
103104
supports_cast_with_precision: bool
104105
time_cast_precision: int

django-stubs/db/models/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ from .expressions import ValueRange as ValueRange
4141
from .expressions import When as When
4242
from .expressions import Window as Window
4343
from .expressions import WindowFrame as WindowFrame
44+
from .expressions import WindowFrameExclusion as WindowFrameExclusion
4445
from .fields import NOT_PROVIDED as NOT_PROVIDED
4546
from .fields import AutoField as AutoField
4647
from .fields import BigAutoField as BigAutoField

django-stubs/db/models/expressions.pyi

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
33
from decimal import Decimal
4+
from enum import Enum
45
from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar
56

67
from django.db.backends.base.base import BaseDatabaseWrapper
@@ -298,13 +299,25 @@ class Window(SQLiteNumericMixin, Expression):
298299
output_field: Field | None = None,
299300
) -> None: ...
300301

302+
class WindowFrameExclusion(Enum):
303+
CURRENT_ROW = "CURRENT ROW"
304+
GROUP = "GROUP"
305+
TIES = "TIES"
306+
NO_OTHERS = "NO OTHERS"
307+
301308
class WindowFrame(Expression):
302309
template: str
303310
frame_type: str
304-
def __init__(self, start: int | None = None, end: int | None = None) -> None: ...
311+
def __init__(
312+
self,
313+
start: int | None = None,
314+
end: int | None = None,
315+
exclusion: WindowFrameExclusion | None = None,
316+
) -> None: ...
305317
def window_frame_start_end(
306318
self, connection: BaseDatabaseWrapper, start: int | None, end: int | None
307319
) -> tuple[int, int]: ...
320+
def get_exclusion(self) -> str: ...
308321

309322
class RowRange(WindowFrame): ...
310323
class ValueRange(WindowFrame): ...

scripts/stubtest/allowlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ django.db.backends.mysql.features.DatabaseFeatures.supports_index_column_orderin
266266
django.db.backends.mysql.features.DatabaseFeatures.supports_transactions
267267
django.db.backends.mysql.features.DatabaseFeatures.update_can_self_select
268268
django.db.backends.oracle.features.DatabaseFeatures.supports_boolean_expr_in_select_clause
269+
django.db.backends.oracle.features.DatabaseFeatures.supports_frame_exclusion
269270
django.db.backends.postgresql.base.DatabaseWrapper.pg_version
270271
django.db.backends.postgresql.features.DatabaseFeatures.is_postgresql_13
271272
django.db.migrations.RenameField.new_name_lower

scripts/stubtest/allowlist_todo_django51.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ django.contrib.gis.db.backends.mysql.operations.MySQLOperations.collect
2020
django.contrib.gis.db.models.ForeignObjectRel.accessor_name
2121
django.contrib.gis.db.models.ForeignObjectRel.cache_name
2222
django.contrib.gis.db.models.OrderBy.constraint_validation_compatible
23-
django.contrib.gis.db.models.WindowFrame.__init__
24-
django.contrib.gis.db.models.WindowFrame.get_exclusion
25-
django.contrib.gis.db.models.WindowFrameExclusion
2623
django.contrib.gis.db.models.functions.FromWKB.__init__
2724
django.contrib.gis.db.models.functions.FromWKB.as_oracle
2825
django.contrib.gis.db.models.functions.FromWKB.output_field
@@ -70,7 +67,6 @@ django.core.files.storage.filesystem.FileSystemStorage.__init__
7067
django.core.files.storage.filesystem.FileSystemStorage.is_name_available
7168
django.core.files.storage.get_storage_class
7269
django.core.signing.Signer.__init__
73-
django.db.backends.base.features.BaseDatabaseFeatures.supports_frame_exclusion
7470
django.db.backends.base.operations.BaseDatabaseOperations.bulk_insert_sql
7571
django.db.backends.base.operations.BaseDatabaseOperations.force_group_by
7672
django.db.backends.base.operations.BaseDatabaseOperations.window_frame_end
@@ -82,29 +78,20 @@ django.db.backends.ddl_references.Table.references_index
8278
django.db.backends.oracle.features.DatabaseFeatures.bare_select_suffix
8379
django.db.backends.oracle.features.DatabaseFeatures.supports_aggregation_over_interval_types
8480
django.db.backends.oracle.features.DatabaseFeatures.supports_comparing_boolean_expr
85-
django.db.backends.oracle.features.DatabaseFeatures.supports_frame_exclusion
8681
django.db.backends.postgresql.base.DatabaseWrapper.close_pool
8782
django.db.backends.postgresql.base.DatabaseWrapper.pool
8883
django.db.backends.postgresql.features.DatabaseFeatures.django_test_skips
8984
django.db.backends.postgresql.features.DatabaseFeatures.is_postgresql_16
90-
django.db.backends.postgresql.features.DatabaseFeatures.supports_frame_exclusion
9185
django.db.backends.sqlite3.base.DatabaseWrapper.transaction_modes
92-
django.db.backends.sqlite3.features.DatabaseFeatures.supports_frame_exclusion
9386
django.db.backends.sqlite3.operations.DatabaseOperations.force_group_by
9487
django.db.migrations.autodetector.MigrationAutodetector.generate_altered_index_together
9588
django.db.migrations.autodetector.OperationDependency
9689
django.db.models.ForeignObjectRel.accessor_name
9790
django.db.models.ForeignObjectRel.cache_name
9891
django.db.models.OrderBy.constraint_validation_compatible
99-
django.db.models.WindowFrame.__init__
100-
django.db.models.WindowFrame.get_exclusion
101-
django.db.models.WindowFrameExclusion
10292
django.db.models.expressions.BaseExpression.constraint_validation_compatible
10393
django.db.models.expressions.BaseExpression.get_expression_for_validation
10494
django.db.models.expressions.OrderBy.constraint_validation_compatible
105-
django.db.models.expressions.WindowFrame.__init__
106-
django.db.models.expressions.WindowFrame.get_exclusion
107-
django.db.models.expressions.WindowFrameExclusion
10895
django.db.models.fields.mixins.FieldCacheMixin.cache_name
10996
django.db.models.fields.related.ForeignObjectRel.accessor_name
11097
django.db.models.fields.related.ForeignObjectRel.cache_name

0 commit comments

Comments
 (0)