Closed ianturton closed 1 year ago
That's a nasty one. The escape characters are removed as soon as they become strings in Python, so by the time they reach the parser they are seen as two separate string tokens.
>>> s = "where \"CaseFullRef\" < '09/P/99999')"
>>> print(s)
where "CaseFullRef" < '09/P/99999')
Just to check - do the field names have to be wrapped in double quotes to work in MapServer? There was a discussion at https://github.com/MapServer/MapServer/issues/3226 and code at https://github.com/MapServer/MapServer/blob/5dbbf8a19abb2f30b4852b72c8661faac14ae4c9/mappostgis.cpp#L1577 that looks like the field names could be automatically wrapped in quotes?
Possibly just wishful thinking though..
@ianturton - actually this should be supported, see the test at https://github.com/geographika/mappyfile/blob/15748919b921e1df65bcf812033c40c515568a3f/tests/test_snippets.py#L733
How are you calling mappyfile? You need to pass in a raw string for it to work correctly. I might need to add this to the high-level functions if this is not working correctly.
>>> s = r"where \"CaseFullRef\" < '09/P/99999')"
>>> print(s)
where \"CaseFullRef\" < '09/P/99999')
That does fix it, thanks.
Given a map file like:
The Data element of the dictionary returned is
'wkb_geometry from (select * FROM PLANNING_SCHEMA.allplanning_2000_onwards_polys_and_data where '
with another element with keycasefullref
and value< '09/P/99999') as foo using unique ogc_fid using srid=27700
While I'd like to beat my users over the head for using mixed case attribute names in PostGIS, I can't actually convince them to change them.