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
3 changes: 2 additions & 1 deletion src/firebolt/async_db/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from collections import namedtuple
from datetime import date, datetime, timezone
from decimal import Decimal
from enum import Enum
from typing import List, Sequence, Union

Expand Down Expand Up @@ -206,7 +207,7 @@ def format_value(value: ParameterType) -> str:
"""For python value to be used in a SQL query"""
if isinstance(value, bool):
return str(int(value))
if isinstance(value, (int, float)):
if isinstance(value, (int, float, Decimal)):
return str(value)
elif isinstance(value, str):
return f"'{''.join(escape_chars.get(c, c) for c in value)}'"
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/async_db/test_typing_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
from typing import List

from pytest import mark, raises
Expand All @@ -24,6 +25,8 @@
# Numbers
(1, "1"),
(1.123, "1.123"),
(Decimal("1.123"), "1.123"),
(Decimal(1.123), "1.1229999999999999982236431605997495353221893310546875"),
(True, "1"),
(False, "0"),
# Date, datetime
Expand Down