tegola icon indicating copy to clipboard operation
tegola copied to clipboard

!ZOOM! substitution error

Open pnorman opened this issue 6 years ago • 5 comments

With a query containing the SQL way_area > pixel_size(!ZOOM!)*4 I get ERROR: syntax error at or near "ANY" (SQLSTATE 42601)

Because this is similar to previous problems with st_asbinary, I checked the code

https://github.com/terranodo/tegola/blob/9c523ad35e1e6ce3a06ca09e580518e78ac65622/provider/postgis/postgis.go#L277-L279

Substituting an expression to where an integer is expected isn't safe. Functions that accept zoom as a parameter are reasonably common, e.g. ZRes, or functions which take something that depends on z, like LabelGrid from postgis-vt-util. Many SQL functions are called with something depending on zoom, e.g. ST_SnapToGrid.

Unlike the st_asbinary case, I'm not aware of any workarounds.

pnorman avatar Feb 27 '18 01:02 pnorman

@pnorman you have done a great job identifying various ways the current implementation is brittle. @ear7h is going to take on developing a more robust way to handle SQL substitution during the v0.7.0 milestone. We will be packaging these various issues into test cases so if you hit any additional situations please submit them.

ARolek avatar Mar 01 '18 19:03 ARolek

@pnorman you have done a great job identifying various ways the current implementation is brittle. @ear7h is going to take on developing a more robust way to handle SQL substitution during the v0.7.0 milestone.

Let me know if I can help in some way

We will be packaging these various issues into test cases so if you hit any additional situations please submit them.

Will do.

pnorman avatar Mar 02 '18 05:03 pnorman

!ZOOM! < n and n > !ZOOM! currently act differently, with the former causing a syntax error and the latter working.

pnorman avatar Mar 18 '18 10:03 pnorman

Given that this issue makes !ZOOM! almost impossible to use for anything non-trivial at the moment, and the fact that pretty much everyone uses it to just remove objects at lower zoom levels, could we take the simple approach of replacing that ANY() operator with 24 for the moment?

russss avatar Oct 11 '18 13:10 russss

@pnorman I think you can set the geometry_type on the provider layer to avoid tegola trying to infer the geometry type on startup. Additional details: https://tegola.io/documentation/configuration/#provider-layers

ARolek avatar Feb 26 '19 19:02 ARolek