From c779c23a7bc3e9e5a1277a6c02e225b8c065b061 Mon Sep 17 00:00:00 2001 From: Stepan Burlakov Date: Mon, 4 Aug 2025 10:40:31 +0300 Subject: [PATCH 1/2] add quoted decimal tests --- tests/integration/dbapi/async/V2/test_queries_async.py | 10 ++++++++++ tests/integration/dbapi/conftest.py | 10 ++++++++++ tests/integration/dbapi/sync/V2/test_queries.py | 10 ++++++++++ tests/unit/common/test_typing_parse.py | 4 ++++ 4 files changed, 34 insertions(+) diff --git a/tests/integration/dbapi/async/V2/test_queries_async.py b/tests/integration/dbapi/async/V2/test_queries_async.py index fa8dc0ab12..dca5c97c5b 100644 --- a/tests/integration/dbapi/async/V2/test_queries_async.py +++ b/tests/integration/dbapi/async/V2/test_queries_async.py @@ -598,3 +598,13 @@ async def test_fb_numeric_paramstyle_incorrect_params( assert "Query referenced positional parameter $34, but it was not set" in str( exc_info.value ) + + +async def test_select_quoted_long( + connection: Connection, long_value: str, long_value_sql: str +): + async with connection.cursor() as c: + await c.execute(long_value_sql) + result = await c.fetchall() + assert len(result) == 1, "Invalid data length returned by fetchall" + assert result[0][0] == Decimal(long_value), "Invalid data returned by fetchall" diff --git a/tests/integration/dbapi/conftest.py b/tests/integration/dbapi/conftest.py index 015ab0cb1d..b2b7e1c8ad 100644 --- a/tests/integration/dbapi/conftest.py +++ b/tests/integration/dbapi/conftest.py @@ -273,3 +273,13 @@ def select_struct_description() -> List[Column]: @fixture def select_struct_response() -> List[ColType]: return [[{"id": 1, "s": {"a": [1, 2], "b": datetime(2019, 7, 31, 1, 1, 1)}}]] + + +@fixture +def long_value() -> str: + return "1234567890123456789012345678901234567.0" + + +@fixture +def long_value_sql(long_value: str) -> str: + return f"SELECT '{long_value}'::decimal(38, 1)" diff --git a/tests/integration/dbapi/sync/V2/test_queries.py b/tests/integration/dbapi/sync/V2/test_queries.py index 46e140ba8e..a1df018609 100644 --- a/tests/integration/dbapi/sync/V2/test_queries.py +++ b/tests/integration/dbapi/sync/V2/test_queries.py @@ -673,3 +673,13 @@ def test_fb_numeric_paramstyle_incorrect_params( assert "Query referenced positional parameter $34, but it was not set" in str( exc_info.value ) + + +def test_select_quoted_long( + connection: Connection, long_value: str, long_value_sql: str +): + with connection.cursor() as c: + c.execute(long_value_sql) + result = c.fetchall() + assert len(result) == 1, "Invalid data length returned by fetchall" + assert result[0][0] == Decimal(long_value), "Invalid data returned by fetchall" diff --git a/tests/unit/common/test_typing_parse.py b/tests/unit/common/test_typing_parse.py index 67289b09c2..eb32c4ad2a 100644 --- a/tests/unit/common/test_typing_parse.py +++ b/tests/unit/common/test_typing_parse.py @@ -220,6 +220,10 @@ def test_parse_value_datetime_errors() -> None: ("123.456", Decimal("123.456")), (123, Decimal("123")), (None, None), + ( + "1234567890123456789012345678901234567.0", + Decimal("1234567890123456789012345678901234567.0"), + ), ], ) def test_parse_decimal(value, expected) -> None: From e93837b6da21c209d4c3082cdae89d68b9bb1634 Mon Sep 17 00:00:00 2001 From: Stepan Burlakov Date: Mon, 4 Aug 2025 10:49:10 +0300 Subject: [PATCH 2/2] add long bigint tests --- .../dbapi/async/V2/test_queries_async.py | 22 +++++++++++++++---- tests/integration/dbapi/conftest.py | 16 +++++++++++--- .../integration/dbapi/sync/V2/test_queries.py | 22 +++++++++++++++---- tests/unit/common/test_typing_parse.py | 1 + 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/tests/integration/dbapi/async/V2/test_queries_async.py b/tests/integration/dbapi/async/V2/test_queries_async.py index dca5c97c5b..e16c7808f0 100644 --- a/tests/integration/dbapi/async/V2/test_queries_async.py +++ b/tests/integration/dbapi/async/V2/test_queries_async.py @@ -600,11 +600,25 @@ async def test_fb_numeric_paramstyle_incorrect_params( ) -async def test_select_quoted_long( - connection: Connection, long_value: str, long_value_sql: str +async def test_select_quoted_decimal( + connection: Connection, long_decimal_value: str, long_value_decimal_sql: str ): async with connection.cursor() as c: - await c.execute(long_value_sql) + await c.execute(long_value_decimal_sql) result = await c.fetchall() assert len(result) == 1, "Invalid data length returned by fetchall" - assert result[0][0] == Decimal(long_value), "Invalid data returned by fetchall" + assert result[0][0] == Decimal( + long_decimal_value + ), "Invalid data returned by fetchall" + + +async def test_select_quoted_bigint( + connection: Connection, long_bigint_value: str, long_value_bigint_sql: str +): + async with connection.cursor() as c: + await c.execute(long_value_bigint_sql) + result = await c.fetchall() + assert len(result) == 1, "Invalid data length returned by fetchall" + assert result[0][0] == int( + long_bigint_value + ), "Invalid data returned by fetchall" diff --git a/tests/integration/dbapi/conftest.py b/tests/integration/dbapi/conftest.py index b2b7e1c8ad..6ec89708a8 100644 --- a/tests/integration/dbapi/conftest.py +++ b/tests/integration/dbapi/conftest.py @@ -276,10 +276,20 @@ def select_struct_response() -> List[ColType]: @fixture -def long_value() -> str: +def long_decimal_value() -> str: return "1234567890123456789012345678901234567.0" @fixture -def long_value_sql(long_value: str) -> str: - return f"SELECT '{long_value}'::decimal(38, 1)" +def long_value_decimal_sql(long_decimal_value: str) -> str: + return f"SELECT '{long_decimal_value}'::decimal(38, 1)" + + +@fixture +def long_bigint_value() -> str: + return "123456789012345678" + + +@fixture +def long_value_bigint_sql(long_bigint_value: str) -> str: + return f"SELECT '{long_bigint_value}'::bigint" diff --git a/tests/integration/dbapi/sync/V2/test_queries.py b/tests/integration/dbapi/sync/V2/test_queries.py index a1df018609..9b415cef88 100644 --- a/tests/integration/dbapi/sync/V2/test_queries.py +++ b/tests/integration/dbapi/sync/V2/test_queries.py @@ -675,11 +675,25 @@ def test_fb_numeric_paramstyle_incorrect_params( ) -def test_select_quoted_long( - connection: Connection, long_value: str, long_value_sql: str +def test_select_quoted_decimal( + connection: Connection, long_decimal_value: str, long_value_decimal_sql: str ): with connection.cursor() as c: - c.execute(long_value_sql) + c.execute(long_value_decimal_sql) result = c.fetchall() assert len(result) == 1, "Invalid data length returned by fetchall" - assert result[0][0] == Decimal(long_value), "Invalid data returned by fetchall" + assert result[0][0] == Decimal( + long_decimal_value + ), "Invalid data returned by fetchall" + + +def test_select_quoted_bigint( + connection: Connection, long_bigint_value: str, long_value_bigint_sql: str +): + with connection.cursor() as c: + c.execute(long_value_bigint_sql) + result = c.fetchall() + assert len(result) == 1, "Invalid data length returned by fetchall" + assert result[0][0] == int( + long_bigint_value + ), "Invalid data returned by fetchall" diff --git a/tests/unit/common/test_typing_parse.py b/tests/unit/common/test_typing_parse.py index eb32c4ad2a..42b224b1d4 100644 --- a/tests/unit/common/test_typing_parse.py +++ b/tests/unit/common/test_typing_parse.py @@ -53,6 +53,7 @@ def test_parse_struct_type_with_spaces() -> None: ((1,), None, TypeError), ([1], None, TypeError), (Exception(), None, TypeError), + ("123456789012345678", 123456789012345678, None), ], ) def test_parse_value_int(value, expected, error) -> None: