Skip to content

Commit

Permalink
feat: added support for numeric field for python decimal value (#316)
Browse files Browse the repository at this point in the history
* feat: updated googleapis proto changes for request tags

* feat: added support for numberic for python decimal value

* feat: added support for numberic for python decimal value
  • Loading branch information
vi3k6i5 committed Apr 23, 2021
1 parent 7015fd6 commit 070a171
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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

0 comments on commit 070a171

Please sign in to comment.