File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,26 @@ class Column(BaseModel):
1313 type : str
1414 description : Optional [str ]
1515
16+ @property
17+ def json_type (self ):
18+ """Return JSON field type."""
19+ type = self .type
20+ if any (
21+ [
22+ type .startswith ("int" ),
23+ type .startswith ("num" ),
24+ type .startswith ("float" ),
25+ ]
26+ ):
27+ return "number"
28+ if type .startswith ("bool" ):
29+ return "boolean"
30+ if type .endswith ("[]" ):
31+ return "array"
32+ if any ([type .startswith ("json" ), type .startswith ("geo" )]):
33+ return "object"
34+ return "string"
35+
1636
1737class GeometryColumn (BaseModel ):
1838 """Model for PostGIS geometry/geography column."""
Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ def queryables(self) -> Dict:
438438 for col in geometries
439439 }
440440 props = {
441- col .name : {"name" : col .name , "type" : col .type }
441+ col .name : {"name" : col .name , "type" : col .json_type }
442442 for col in self .properties
443443 if col .name not in geoms
444444 }
You can’t perform that action at this time.
0 commit comments