Skip to content

Commit 5ef10d9

Browse files
authored
Support PgArray columns (#63)
* Support PgArray columns * Reformat test_models Co-authored-by: Sergio Durban Belmonte <sdurban@leadtech.com>
1 parent a0931a4 commit 5ef10d9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

local_data_api/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def from_value(cls, value: Any) -> Field:
4747
return cls(stringValue=str(value))
4848
elif type(value).__name__.endswith('BigInteger'):
4949
return cls(longValue=int(str(value)))
50+
elif type(value).__name__.endswith('PgArray'):
51+
return cls(stringValue=str(value))
5052
else:
5153
raise Exception(f'unsupported type {type(value)}: {value} ')
5254

tests/test_models.py

+11
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ def __str__(self) -> int:
8484

8585
assert Field.from_value(BigInteger("55")) == Field(longValue=55)
8686

87+
class PgArray:
88+
def __init__(self, val: str):
89+
self._val: str = val
90+
91+
def __str__(self) -> str:
92+
return self._val
93+
94+
assert Field.from_value(PgArray("{ITEM1,ITEM2}")) == Field(
95+
stringValue="{ITEM1,ITEM2}"
96+
)
97+
8798
class Dummy:
8899
pass
89100

0 commit comments

Comments
 (0)