SQL drivers : bad AND priority when spatial and attribute filter are combined
|Reported by:||Even Rouault||Owned by:||warmerdam|
At least for PG, MySQL, SQLite and MSSpatial driver (and probably in other drivers), when we build the where clause, we build something like "WHERE spatial_filter AND attribute_filter". The issue is that if attribute_filter contains a OR, we end up with "WHERE spatial_filter AND attribute_filter_part1 OR attribute_filter_part2", which evaluates to "WHERE (spatial_filter AND attribute_filter_part1) OR attribute_filter_part2".
Which queries more features than really necessary. Generally, you won't notice it since client side spatial filtering will still be done. But this can be sometimes seen when running GetFeatureCount().