From c99c4a79e4a84a274dcb486c2f95724f02cc02b7 Mon Sep 17 00:00:00 2001 From: Daven Quinn Date: Fri, 10 May 2024 03:29:18 -0400 Subject: [PATCH] Updated column name subsetting --- timvt/layer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/timvt/layer.py b/timvt/layer.py index 9fbd9ae..1cc7596 100644 --- a/timvt/layer.py +++ b/timvt/layer.py @@ -6,7 +6,7 @@ from typing import Any, ClassVar, Dict, List, Optional import morecantile -from buildpg import Func +from buildpg import Func, RawDangerous from buildpg import Var as pg_variable from buildpg import asyncpg, clauses, funcs, render, select_fields from pydantic import BaseModel, root_validator @@ -157,6 +157,12 @@ async def get_tile( tms_srid = tms.crs.to_epsg() tms_proj = tms.crs.to_proj4() + # This may be more valid but it doesn't add quotes around the column names + # _fields = select_fields(*cols) + + _fields = [f'"{f}"' for f in cols] + _fields = ", ".join(_fields) + async with pool.acquire() as conn: sql_query = """ WITH @@ -209,7 +215,7 @@ async def get_tile( sql_query, tablename=pg_variable(self.id), geometry_column=pg_variable(geometry_column.name), - fields=select_fields(*cols), + fields=RawDangerous(_fields), xmin=bbox.left, ymin=bbox.bottom, xmax=bbox.right,