diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index 60ce9b177e..59e75f9b3e 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -1549,7 +1549,7 @@ def get_task_geometry(db: Session, project_id: int): async def get_project_features_geojson(db:Session, project_id:int): # Get the geojson of those features for this task. - query = f"""SELECT jsonb_build_object( + query = text(f"""SELECT jsonb_build_object( 'type', 'FeatureCollection', 'features', jsonb_agg(feature) ) @@ -1563,7 +1563,7 @@ async def get_project_features_geojson(db:Session, project_id:int): FROM features WHERE project_id={project_id} ) features; - """ + """) result = db.execute(query) features = result.fetchone()[0] @@ -2088,7 +2088,7 @@ async def update_project_form( # Get the features for this task. # Postgis query to filter task inside this task outline and of this project # Update those features and set task_id - query = f"""UPDATE features + query = text(f"""UPDATE features SET task_id={task} WHERE id in ( @@ -2096,12 +2096,12 @@ async def update_project_form( FROM features WHERE project_id={project_id} and ST_Intersects(geometry, '{task_obj.outline}'::Geometry) - )""" + )""") result = db.execute(query) # Get the geojson of those features for this task. - query = f"""SELECT jsonb_build_object( + query = text(f"""SELECT jsonb_build_object( 'type', 'FeatureCollection', 'features', jsonb_agg(feature) ) @@ -2114,7 +2114,7 @@ async def update_project_form( ) AS feature FROM features WHERE project_id={project_id} and task_id={task} - ) features;""" + ) features;""") result = db.execute(query) features = result.fetchone()[0] @@ -2154,7 +2154,7 @@ async def update_odk_credentials( async def get_extracted_data_from_db(db: Session, project_id: int, outfile: str): """Get the geojson of those features for this project.""" - query = f"""SELECT jsonb_build_object( + query = text(f"""SELECT jsonb_build_object( 'type', 'FeatureCollection', 'features', jsonb_agg(feature) ) @@ -2167,7 +2167,7 @@ async def get_extracted_data_from_db(db: Session, project_id: int, outfile: str) ) AS feature FROM features WHERE project_id={project_id} - ) features;""" + ) features;""") result = db.execute(query) features = result.fetchone()[0] @@ -2208,7 +2208,7 @@ def get_project_tiles( db.commit() # Project Outline - query = f"""SELECT jsonb_build_object( + query = text(f"""SELECT jsonb_build_object( 'type', 'FeatureCollection', 'features', jsonb_agg(feature) ) @@ -2220,7 +2220,7 @@ def get_project_tiles( ) AS feature FROM projects WHERE id={project_id} - ) features;""" + ) features;""") result = db.execute(query) features = result.fetchone()[0] diff --git a/src/backend/app/tasks/tasks_crud.py b/src/backend/app/tasks/tasks_crud.py index a1cc26c9e3..21a9d48afb 100644 --- a/src/backend/app/tasks/tasks_crud.py +++ b/src/backend/app/tasks/tasks_crud.py @@ -43,7 +43,7 @@ async def get_task_count_in_project(db: Session, project_id: int): - query = f"""select count(*) from tasks where project_id = {project_id}""" + query = text(f"""select count(*) from tasks where project_id = {project_id}""") result = db.execute(query) return result.fetchone()[0]