Skip to content

Commit 48a95c0

Browse files
test(FIR-34592): add quoted decimal and bigint tests (#452)
1 parent 040471c commit 48a95c0

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

tests/integration/dbapi/async/V2/test_queries_async.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,3 +598,27 @@ async def test_fb_numeric_paramstyle_incorrect_params(
598598
assert "Query referenced positional parameter $34, but it was not set" in str(
599599
exc_info.value
600600
)
601+
602+
603+
async def test_select_quoted_decimal(
604+
connection: Connection, long_decimal_value: str, long_value_decimal_sql: str
605+
):
606+
async with connection.cursor() as c:
607+
await c.execute(long_value_decimal_sql)
608+
result = await c.fetchall()
609+
assert len(result) == 1, "Invalid data length returned by fetchall"
610+
assert result[0][0] == Decimal(
611+
long_decimal_value
612+
), "Invalid data returned by fetchall"
613+
614+
615+
async def test_select_quoted_bigint(
616+
connection: Connection, long_bigint_value: str, long_value_bigint_sql: str
617+
):
618+
async with connection.cursor() as c:
619+
await c.execute(long_value_bigint_sql)
620+
result = await c.fetchall()
621+
assert len(result) == 1, "Invalid data length returned by fetchall"
622+
assert result[0][0] == int(
623+
long_bigint_value
624+
), "Invalid data returned by fetchall"

tests/integration/dbapi/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,23 @@ def select_struct_description() -> List[Column]:
273273
@fixture
274274
def select_struct_response() -> List[ColType]:
275275
return [[{"id": 1, "s": {"a": [1, 2], "b": datetime(2019, 7, 31, 1, 1, 1)}}]]
276+
277+
278+
@fixture
279+
def long_decimal_value() -> str:
280+
return "1234567890123456789012345678901234567.0"
281+
282+
283+
@fixture
284+
def long_value_decimal_sql(long_decimal_value: str) -> str:
285+
return f"SELECT '{long_decimal_value}'::decimal(38, 1)"
286+
287+
288+
@fixture
289+
def long_bigint_value() -> str:
290+
return "123456789012345678"
291+
292+
293+
@fixture
294+
def long_value_bigint_sql(long_bigint_value: str) -> str:
295+
return f"SELECT '{long_bigint_value}'::bigint"

tests/integration/dbapi/sync/V2/test_queries.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,27 @@ def test_fb_numeric_paramstyle_incorrect_params(
673673
assert "Query referenced positional parameter $34, but it was not set" in str(
674674
exc_info.value
675675
)
676+
677+
678+
def test_select_quoted_decimal(
679+
connection: Connection, long_decimal_value: str, long_value_decimal_sql: str
680+
):
681+
with connection.cursor() as c:
682+
c.execute(long_value_decimal_sql)
683+
result = c.fetchall()
684+
assert len(result) == 1, "Invalid data length returned by fetchall"
685+
assert result[0][0] == Decimal(
686+
long_decimal_value
687+
), "Invalid data returned by fetchall"
688+
689+
690+
def test_select_quoted_bigint(
691+
connection: Connection, long_bigint_value: str, long_value_bigint_sql: str
692+
):
693+
with connection.cursor() as c:
694+
c.execute(long_value_bigint_sql)
695+
result = c.fetchall()
696+
assert len(result) == 1, "Invalid data length returned by fetchall"
697+
assert result[0][0] == int(
698+
long_bigint_value
699+
), "Invalid data returned by fetchall"

tests/unit/common/test_typing_parse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_parse_struct_type_with_spaces() -> None:
5353
((1,), None, TypeError),
5454
([1], None, TypeError),
5555
(Exception(), None, TypeError),
56+
("123456789012345678", 123456789012345678, None),
5657
],
5758
)
5859
def test_parse_value_int(value, expected, error) -> None:
@@ -220,6 +221,10 @@ def test_parse_value_datetime_errors() -> None:
220221
("123.456", Decimal("123.456")),
221222
(123, Decimal("123")),
222223
(None, None),
224+
(
225+
"1234567890123456789012345678901234567.0",
226+
Decimal("1234567890123456789012345678901234567.0"),
227+
),
223228
],
224229
)
225230
def test_parse_decimal(value, expected) -> None:

0 commit comments

Comments
 (0)