Refs #26608 -- Added a database feature for fixed frame range distance support.

This commit is contained in:
Simon Charette 2019-01-15 22:23:50 -06:00 committed by Tim Graham
parent 64d5bafbc6
commit b8c48d06fa
3 changed files with 3 additions and 2 deletions

View File

@ -239,6 +239,7 @@ class BaseDatabaseFeatures:
# Does the backend support window expressions (expression OVER (...))? # Does the backend support window expressions (expression OVER (...))?
supports_over_clause = False supports_over_clause = False
supports_frame_range_fixed_distance = False
# Does the backend support CAST with precision? # Does the backend support CAST with precision?
supports_cast_with_precision = True supports_cast_with_precision = True

View File

@ -52,6 +52,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
""" """
supports_callproc_kwargs = True supports_callproc_kwargs = True
supports_over_clause = True supports_over_clause = True
supports_frame_range_fixed_distance = True
supports_ignore_conflicts = False supports_ignore_conflicts = False
max_query_params = 2**16 - 1 max_query_params = 2**16 - 1
supports_partial_indexes = False supports_partial_indexes = False

View File

@ -536,8 +536,7 @@ class WindowFunctionTests(TestCase):
('Brown', 53000, 'Sales', datetime.date(2009, 9, 1), 108000), ('Brown', 53000, 'Sales', datetime.date(2009, 9, 1), 108000),
], transform=lambda row: (row.name, row.salary, row.department, row.hire_date, row.sum)) ], transform=lambda row: (row.name, row.salary, row.department, row.hire_date, row.sum))
@skipIf(connection.vendor == 'postgresql', 'n following/preceding not supported by PostgreSQL') @skipUnlessDBFeature('supports_frame_range_fixed_distance')
@skipIf(connection.vendor == 'sqlite', 'n following/preceding not supported by SQLite')
def test_range_n_preceding_and_following(self): def test_range_n_preceding_and_following(self):
qs = Employee.objects.annotate(sum=Window( qs = Employee.objects.annotate(sum=Window(
expression=Sum('salary'), expression=Sum('salary'),