<div dir="ltr">I'm using MapServer 6.4 and I have an SLD file (attached below) that contains the SLD for two named layers that I want to draw. This will fail with an SQL error like:<div><br></div><div><div>[Tue Jan 03 15:47:02 2017].372000 msPostGISLayerWhichShapes(): Query error. Error (ERROR:  syntax error at or near ")"</div><div>LINE 1: ...8249.045869014 463450.560844313))',27700) and ("id"= 100) ))</div><div>                                                                     ^</div><div>) executing query: select "id",encode(ST_AsBinary(ST_Force_2D("wkb_geometry"),'NDR'),'hex') as geom,"id" from ( SELECT "id", "wkb_geometry", "name", "created_date" FROM (SELECT * FROM "nsips"."app_sites")  d ) AS qq where wkb_geometry && GeomFromText('POLYGON((288249.045869014 463450.560844313,288249.045869014 645745.639155687,569171.454130986 645745.639155687,569171.454130986 463450.560844313,288249.045869014 463450.560844313))',27700) and ("id"= 100) ))</div><div>[Tue Jan 03 15:47:02 2017].372000 msDrawMap(): Image handling error. Failed to draw layer named 'app_sites'.</div><div><br></div><div>And it is quite correct that is an invalid SQL - if you delete the last two ) it works fine and returns the required feature.</div><div><br></div><div>However if I comment out the filter from either of the layers I get a map (with too many features drawn).</div><div><br></div><div>The only related issue I can see is <a href="https://github.com/mapserver/mapserver/issues/5154">https://github.com/mapserver/mapserver/issues/5154</a> but I'm not sure that it really applies.</div><div><br></div><div>Cheers</div><div><br></div><div>Ian</div><div><br></div>-- <br><div class="gmail_signature">Ian Turton<br></div>
</div></div>