Skip to content

Commit

Permalink
fix: change geom to geojson in db model
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujanadh committed Jan 10, 2025
1 parent 72653c7 commit 2758f38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ def slugify(name: Optional[str]) -> Optional[str]:
class DbGeometryLog(BaseModel):
"""Table geometry log."""

geom: dict
geojson: dict
status: GeomStatus
project_id: Optional[int] = None
task_id: Optional[int] = None
Expand All @@ -1766,8 +1766,8 @@ async def create(

for key in model_dump.keys():
columns.append(key)
if key == "geom":
value_placeholders.append(f"ST_GeomFromGeoJSON(%({key})s)")
if key == "geojson":
value_placeholders.append(f"%({key})s::jsonb")
# Must be string json for db input
model_dump[key] = json.dumps(model_dump[key])
else:
Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class GeometryLogIn(BaseModel):
"""Geometry log insert."""

status: GeomStatus
geom: dict
geojson: dict
project_id: Optional[int] = None
task_id: Optional[int] = None

@field_validator("geom", mode="before")
@field_validator("geojson", mode="before")
@classmethod
def parse_input_geometry(
cls,
Expand Down

0 comments on commit 2758f38

Please sign in to comment.