Skip to content

Commit

Permalink
Updated column name subsetting
Browse files Browse the repository at this point in the history
  • Loading branch information
davenquinn committed May 10, 2024
1 parent 50ff8f2 commit c99c4a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions timvt/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c99c4a7

Please sign in to comment.