From: Violet Folino Gallo <48537601+galloviolet@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:50:55 +0000 (-0700) Subject: account for sql server in test_window_range X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c37334116f7ac6c3a2bfd8718e28bd197dc08d8c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git account for sql server in test_window_range --- diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index 0b55a57c13..97833149b5 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -45,6 +45,7 @@ from ... import union from ... import values from ...exc import DatabaseError from ...exc import ProgrammingError +from ...sql.elements import _FrameClauseType class CollateTest(fixtures.TablesTest): @@ -1945,17 +1946,29 @@ class WindowFunctionTest(fixtures.TablesTest): def test_window_range(self, connection): some_table = self.tables.some_table - rows = connection.execute( - select( - func.max(some_table.c.col3).over( - partition_by=[some_table.c.col3], - order_by=[some_table.c.col3.asc()], - range_=(-1.25, 1.25), + # SQL Server only allows UNBOUNDED and CURRENT ROW in the RANGE clause + if config.db.dialect in ["mssql+aiodbc", "mssql+pymssql", "mssql+pyodbc"]: + rows = connection.execute( + select( + func.max(some_table.c.col1).over( + partition_by=[some_table.c.col2], + order_by=[some_table.c.col2.asc()], + range_=(_FrameClauseType.RANGE_UNBOUNDED, _FrameClauseType.RANGE_CURRENT) + ) ) - ).where(some_table.c.col1 < 20) - ).all() + ) + else: + rows = connection.execute( + select( + func.max(some_table.c.col3).over( + partition_by=[some_table.c.col3], + order_by=[some_table.c.col3.asc()], + range_=(-1.25, 1.25), + ) + ).where(some_table.c.col1 < 20) + ).all() - eq_(rows, [(i + 1.5,) for i in range(19)]) + eq_(rows, [(i + 1.5,) for i in range(19)]) def test_window_rows_between_w_caching(self, connection): some_table = self.tables.some_table