Skip to content

Commit

Permalink
Add tests for ListParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
baluyotraf committed May 21, 2024
1 parent 3c4e6ba commit 23ca7d7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def mysql(self) -> altqq.MySQLQuery:


class SelectWithCalculated(altqq.Query):
"""Tests queries that uses multiple calculated values."""
"""Test queries that uses multiple calculated values."""

__query__ = """
SELECT * FROM Table WHERE A = {param} AND B = {calc1} AND C = {calc2}
Expand All @@ -40,6 +40,16 @@ def __post_init__(self):
self.calc2 = 30


class SelectWithList(altqq.Query):
"""Test query that uses a list."""

__query__ = """
SELECT * FROM table WHERE A IN {list}
"""

list: altqq.ListParameter[int]


class SelectTableByFilter(altqq.Query):
"""Test query that selects and filters a table."""

Expand Down Expand Up @@ -92,6 +102,17 @@ class UnionAllQuery(altqq.Query):
),
plain_text="""SELECT * FROM Table WHERE A = 10 AND B = 20 AND C = 30""",
),
SampleQuery(
SelectWithList([10, 20, 30]),
pyodbc=altqq.PyODBCQuery(
query="""SELECT * FROM table WHERE A IN (?,?,?)""", parameters=[10, 20, 30]
),
psycopg=altqq.PsycopgQuery(
query="""SELECT * FROM table WHERE A IN (%s,%s,%s)""",
parameters=(10, 20, 30),
),
plain_text="""SELECT * FROM table WHERE A IN (10,20,30)""",
),
SampleQuery(
SelectTableByFilter("Users", "age", 25),
pyodbc=altqq.PyODBCQuery(
Expand Down

0 comments on commit 23ca7d7

Please sign in to comment.