Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for numeric field for python decimal value #316

Merged
merged 8 commits into from Apr 23, 2021
1 change: 1 addition & 0 deletions google/cloud/spanner_dbapi/parse_utils.py
Expand Up @@ -37,6 +37,7 @@
datetime.date: spanner.param_types.DATE,
DateStr: spanner.param_types.DATE,
TimestampStr: spanner.param_types.TIMESTAMP,
decimal.Decimal: spanner.param_types.NUMERIC,
}

SPANNER_RESERVED_KEYWORDS = {
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/spanner_dbapi/test_parse_utils.py
Expand Up @@ -353,6 +353,7 @@ def test_cast_for_spanner(self):
@unittest.skipIf(skip_condition, skip_message)
def test_get_param_types(self):
import datetime
import decimal

from google.cloud.spanner_dbapi.parse_utils import DateStr
from google.cloud.spanner_dbapi.parse_utils import TimestampStr
Expand All @@ -369,6 +370,7 @@ def test_get_param_types(self):
"h1": datetime.date(2011, 9, 1),
"i1": b"bytes",
"j1": None,
"k1": decimal.Decimal("3.194387483193242e+19"),
}
want_types = {
"a1": param_types.INT64,
Expand All @@ -380,6 +382,7 @@ def test_get_param_types(self):
"g1": param_types.TIMESTAMP,
"h1": param_types.DATE,
"i1": param_types.BYTES,
"k1": param_types.NUMERIC,
}
got_types = get_param_types(params)
self.assertEqual(got_types, want_types)
Expand Down