SLD filter "Not PropertyIsEqualTo": SQL inconsistent with Java for null values
------------------------------------------------------------------------------

                 Key: GEOT-3949
                 URL: https://jira.codehaus.org/browse/GEOT-3949
             Project: GeoTools
          Issue Type: Bug
          Components: jdbc, main
    Affects Versions: 8.0-M3, 2.7.3
         Environment: PostGIS
            Reporter: Norbert Renner


For SLD style rules with a "Not PropertyIsEqualTo" filter, the generated SQL 
where clause does not return the same result for null values as the Java filter 
implementation.

Filter example:

{code:xml}
  <ogc:Filter>
    <ogc:And>
      <ogc:PropertyIsEqualTo>
        <ogc:PropertyName>railway</ogc:PropertyName>
        <ogc:Literal>rail</ogc:Literal>
      </ogc:PropertyIsEqualTo>
      <ogc:Not>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>tunnel</ogc:PropertyName>
          <ogc:Literal>yes</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Not>
    </ogc:And>
  </ogc:Filter>
{code}

Generated SQL:

{code:sql}
SELECT "id","tunnel","railway",encode(ST_AsBinary(ST_Force_2D("way")),'base64') 
as "way" 
  FROM "public"."roads" 
 WHERE ("way" && ST_GeomFromText('POLYGON ((...))', 900913) 
   AND ("railway" = 'rail' AND NOT ("tunnel" = 'yes')))
{code}

This query does not return rows where "tunnel" is null, because in SQL null 
compared with equals is neither true nor false. The problem is, that in the 
Java implementation "null = 'yes'" does evaluate to false:

{code:java}
  IsEqualsToImpl.evaluateInternal(Object value1, Object value2):
    if (value1 == null || value2 == null) {
        return false;
    }
{code}
        
So, if the filter matches features with tunnel=null in this case depends on 
whether SQL pre-filtering is active or not and thus on the 
maxFiltersToSendToDatastore/MAX_FILTER_RULES parameter settings.

My workaraound is to turn off SQL pre-filtering with 
maxFiltersToSendToDatastore/MAX_FILTER_RULES = 0, which is fine in my case.


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to