8000 Fix SQLite Aggregation Protocols by max-muoto · Pull Request #12192 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Fix SQLite Aggregation Protocols #12192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
max-muoto committed Jun 23, 2024
commit c1ca8212266a5489d7c7a99d8438d82f9aae203e
24 changes: 15 additions & 9 deletions stdlib/@tests/test_cases/sqlite3/check_aggregations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sqlite3

import sys

class WindowSumInt:
def __init__(self) -> None:
Expand All @@ -22,7 +22,10 @@ def finalize(self) -> int:
cur = con.execute("CREATE TABLE test(x, y)")
values = [("a", 4), ("b", 5), ("c", 3), ("d", 8), ("e", 1)]
cur.executemany("INSERT INTO test VALUES(?, ?)", values)
con.create_window_function("sumint", 1, WindowSumInt)

if sys.version_info >= (3, 11):
con.create_window_function("sumint", 1, WindowSumInt)

con.create_aggregate("sumint", 1, WindowSumInt)
cur.execute(
"""
Expand All @@ -40,8 +43,9 @@ def _create_window_function() -> WindowSumInt:


# A callable should work as well.
con.create_window_function("sumint", 1, _create_window_function)
con.create_aggregate("sumint", 1, _create_window_function)
if sys.version_info >= (3, 11):
con.create_window_function("sumint", 1, _create_window_function)
con.create_aggregate("sumint", 1, _create_window_function)

# With num_args set to 1, the callable should not be called with more than one.

Expand All @@ -63,10 +67,11 @@ def finalize(self) -> int:
return self.count


con.create_window_function("sumint", 1, WindowSumIntMultiArgs)
con.create_aggregate("sumint", 1, WindowSumIntMultiArgs)
if sys.version_info >= (3, 11):
con.create_window_function("sumint", 1, WindowSumIntMultiArgs)
con.create_window_function("sumint", 2, WindowSumIntMultiArgs)

con.create_window_function("sumint", 2, WindowSumIntMultiArgs)
con.create_aggregate("sumint", 1, WindowSumIntMultiArgs)
con.create_aggregate("sumint", 2, WindowSumIntMultiArgs)


Expand All @@ -88,8 +93,9 @@ def finalize(self) -> str:


# Since the types for `inverse`, `step`, `finalize`, and `value` are not compatible, the following should fail.
con.create_window_function("sumint", 1, WindowSumIntMismatchedArgs) # type: ignore
con.create_window_function("sumint", 2, WindowSumIntMismatchedArgs) # type: ignore
if sys.version_info >= (3, 11):
con.create_window_function("sumint", 1, WindowSumIntMismatchedArgs) # type: ignore
con.create_window_function("sumint", 2, WindowSumIntMismatchedArgs) # type: ignore


class AggMismatchedArgs:
Expand Down
Loading
0