Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/integration/dbapi/async/V2/test_queries_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 20 additions & 0 deletions tests/integration/dbapi/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 24 additions & 0 deletions tests/integration/dbapi/sync/V2/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions tests/unit/common/test_typing_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading