diff --git a/tests/integration/dbapi/async/V2/test_queries_async.py b/tests/integration/dbapi/async/V2/test_queries_async.py index fa8dc0ab12..e16c7808f0 100644 --- a/tests/integration/dbapi/async/V2/test_queries_async.py +++ b/tests/integration/dbapi/async/V2/test_queries_async.py @@ -598,3 +598,27 @@ 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_decimal( + connection: Connection, long_decimal_value: str, long_value_decimal_sql: str +): + async with connection.cursor() as c: + 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_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 015ab0cb1d..6ec89708a8 100644 --- a/tests/integration/dbapi/conftest.py +++ b/tests/integration/dbapi/conftest.py @@ -273,3 +273,23 @@ 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_decimal_value() -> str: + return "1234567890123456789012345678901234567.0" + + +@fixture +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 46e140ba8e..9b415cef88 100644 --- a/tests/integration/dbapi/sync/V2/test_queries.py +++ b/tests/integration/dbapi/sync/V2/test_queries.py @@ -673,3 +673,27 @@ 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_decimal( + connection: Connection, long_decimal_value: str, long_value_decimal_sql: str +): + with connection.cursor() as c: + 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_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 67289b09c2..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: @@ -220,6 +221,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: