]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
split into basic and numeric tests
authorViolet Folino Gallo <48537601+galloviolet@users.noreply.github.com>
Wed, 16 Jul 2025 19:04:54 +0000 (12:04 -0700)
committerViolet Folino Gallo <48537601+galloviolet@users.noreply.github.com>
Wed, 16 Jul 2025 19:04:54 +0000 (12:04 -0700)
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_select.py
test/requirements.py

index f0384eb91af0c4f653d198364bbdb81cb6412408..6fbf4786e137aa3838e3892525be6daedb0c82fe 100644 (file)
@@ -1880,3 +1880,8 @@ class SuiteRequirements(Requirements):
         """Target backend supports custom ESCAPE characters
         with LIKE comparisons"""
         return exclusions.open()
+
+    @property
+    def window_range_numeric(self):
+        """Target backend supports fractional values in RANGE"""
+        return exclusions.closed()
\ No newline at end of file
index 97833149b5d9f5f3fa3526409bc620963a82d766..19979ab392c2e19021e63831a084274460c0e665 100644 (file)
@@ -1944,31 +1944,36 @@ class WindowFunctionTest(fixtures.TablesTest):
 
         eq_(rows, [(95,) for i in range(19)])
 
-    def test_window_range(self, connection):
+    def test_window_range_basic(self, connection):
         some_table = self.tables.some_table
-        # 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)
-                    )
+        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_=(0, 1)
                 )
-            )
-        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()
+            ).where(some_table.c.col1 < 20)
+        ).all()
+
+        eq_(rows, [(i,) for i in range(1, 20)])
+    
+
+    @testing.requires.window_range_numeric
+    def test_window_range_numeric(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),
+                )
+            ).where(some_table.c.col1 < 20)
+        ).all()
+
+        eq_(rows, [(i + 0.5,) for i in range(1, 20)])
 
-            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
index 1f4a4eb392344e9c278f01215df54bc1594cd83e..c1a576b22050b54aec33bc3b2a316bb2b013734f 100644 (file)
@@ -2128,3 +2128,8 @@ class DefaultRequirements(SuiteRequirements):
     def supports_bitwise_shift(self):
         """Target database supports bitwise left or right shift"""
         return fails_on(["oracle"])
+
+    @property
+    def window_range_numeric(self):
+        """Target database supports window functions with fractional RANGE values"""
+        return fails_on(["mssql"])
\ No newline at end of file