mapscript layer.setFilter()
David Niergarth
dn at HDDESIGN.COM
Fri Aug 3 19:26:12 PDT 2007
Ok, I've found that this was a known problem in 4.10.0, fixed subsequently.
http://www.nabble.com/Re%3A-Filter-in-Mapserver-4.10.0-p6967162.html
If you're stuck using 4.10.0, there is a quick fix: wrap the filter in an extra
set of double quotes. For example, change
layer.setFilter('id < 10')
to
layer.setFilter('"id < 10"')
and things will work again. This quoting fix also works for my filters with
subqueries.
http://www.nabble.com/Re%3A-Filter-in-Mapserver-4.10.0-p6903701.html
--David
David Niergarth wrote:
> Hello,
>
> I have a Python mapscript layer that works fine under mapserver 4.8.3
> (Ubuntu Edgy w/ postgresql 8.1) but fails under mapserver 4.10.0 (Ubuntu
> Feisty w/ postgresql 8.2). The problem happens when trying to set a
> filter on a layer.
>
> layer_obj.data = "the_geom from tbl_people_points"
> layer_obj.setFilter(
> "idpeople in (select idpeople from tbl_request_%s) and quality=0"
> % idrequest
> )
>
> Under 4.8.3, the subquery in the filter works just fine. Under 4.10.0,
> however, the filter string is ending up truncated as 'idpeople in '.
>
> Here's are a couple simple filters that still work under 4.10:
>
> layer_obj.setFilter("idpeople = 10")
> layer_obj.setFilter("idpeople = 10 or idpeople = 4")
>
> And here are a couple simple queries that get truncated under 4.10:
>
> layer_obj.setFilter("idpeople <= 10")
> # For this query, layer.getFilterString() returns 'idpeople '.
>
> layer_obj.setFilter("idpeople = 10 or (idpeople = 10)")
> # For this query, layer.getFilterString() returns 'idpeople = 10
> or ')
>
> All the queries above work under 4.8. The truncation in 4.10 leads to an
> obvious SQL syntax error, which is the error I'm seeing reported by
> Python mapscript. Oddly, I'm not seeing these queries show up in my
> postgres log -- but maybe that's a log-level thing.
>
> Does anyone know what might have changed between 4.8 and 4.10? Or is
> this perhaps a bug in 4.10?
>
> Thanks for any ideas,
>
> --David
More information about the MapServer-users
mailing list