I have trouble with a filter _expression_ for a PostGIS DB on the fly with mapscript.

If I define the filter in the mapfile it works fine, eg.
                FILTER "nmlocal like 'Deqin xian'"
MapServer recognises the quotes around the string _expression_ for 'like' and returns the correct result.

However, I need to create this filter on the fly with mapscript (I want a user to supply the string to match), so on my layer I do a
                layer.setFilter("nmlocal like 'Deqin'")

This has the effect that mapserver recognises the quote that begin the 'Deqin' string as the end of the filter, resulting in a syntactically incorrect SQL _expression_. I have tried various quoting formats (backslashed-escaped, even $ and $$ quoting), all with the same result:

prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from yunnancounties_poly WHERE (nmlocal like ) and (the_geom && setSRID( 'BOX3D(97 20, 106.5 29.5)'::BOX3D,find_srid('','yunnancounties_poly','the_geom') ))'

Any idea or suggestion?

Ludwig

Reply via email to