Skip to content

Commit 810336f

Browse files
author
Tim Nyborg
committed
mark NthValue as unsupported, and skip related tests
1 parent 2abea1a commit 810336f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

mssql/functions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import json
55

66
from django import VERSION
7+
from django.db import NotSupportedError
78
from django.db.models import BooleanField, Value
8-
from django.db.models.functions import Cast
9+
from django.db.models.functions import Cast, NthValue
910
from django.db.models.functions.math import ATan2, Log, Ln, Mod, Round
1011
from django.db.models.expressions import Case, Exists, OrderBy, When, Window
1112
from django.db.models.lookups import Lookup, In
@@ -51,6 +52,10 @@ def sqlserver_mod(self, compiler, connection):
5152
)
5253

5354

55+
def sqlserver_nth_value(self, compiler, connection, **extra_content):
56+
raise NotSupportedError('This backend does not support the NthValue function')
57+
58+
5459
def sqlserver_round(self, compiler, connection, **extra_context):
5560
return self.as_sql(compiler, connection, template='%(function)s(%(expressions)s, 0)', **extra_context)
5661

@@ -186,6 +191,7 @@ def json_HasKeyLookup(self, compiler, connection):
186191
Ln.as_microsoft = sqlserver_ln
187192
Log.as_microsoft = sqlserver_log
188193
Mod.as_microsoft = sqlserver_mod
194+
NthValue.as_microsoft = sqlserver_nth_value
189195
Round.as_microsoft = sqlserver_round
190196
Window.as_microsoft = sqlserver_window
191197

testapp/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
'expressions.tests.FTimeDeltaTests.test_duration_with_datetime_microseconds',
5555
'expressions.tests.IterableLookupInnerExpressionsTests.test_expressions_in_lookups_join_choice',
5656
'expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause',
57+
'expressions_window.tests.WindowFunctionTests.test_nth_returns_null',
58+
'expressions_window.tests.WindowFunctionTests.test_nthvalue',
5759
'ordering.tests.OrderingTests.test_orders_nulls_first_on_filtered_subquery',
5860
'queries.test_bulk_update.BulkUpdateNoteTests.test_set_field_to_null',
5961
'get_or_create.tests.UpdateOrCreateTransactionTests.test_creation_in_transaction',

0 commit comments

Comments
 (0)