Skip to content

Commit aa0a72f

Browse files
authored
Support BigInt columns (#54)
Co-authored-by: Sergio Durban Belmonte <sdurban@leadtech.com>
1 parent 2ed6146 commit aa0a72f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

local_data_api/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def from_value(cls, value: Any) -> Field:
4242
return cls(stringValue=str(value))
4343
elif type(value).__name__.endswith('PGobject'):
4444
return cls(stringValue=str(value))
45+
elif type(value).__name__.endswith('BigInteger'):
46+
return cls(longValue=int(str(value)))
4547
else:
4648
raise Exception(f'unsupported type {type(value)}: {value} ')
4749

tests/test_models.py

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ def __str__(self) -> str:
7070

7171
assert Field.from_value(PGobject("{}")) == Field(stringValue="{}")
7272

73+
class BigInteger:
74+
def __init__(self, val: int):
75+
self._val: int = val
76+
77+
def __str__(self) -> int:
78+
return self._val
79+
80+
assert Field.from_value(BigInteger("55")) == Field(longValue=55)
81+
7382
class Dummy:
7483
pass
7584

0 commit comments

Comments
 (0)