Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFeature with 'date' filter doesn't work on MS7 #5104

Closed
ger-benjamin opened this issue Jun 1, 2015 · 7 comments
Closed

GetFeature with 'date' filter doesn't work on MS7 #5104

ger-benjamin opened this issue Jun 1, 2015 · 7 comments

Comments

@ger-benjamin
Copy link

In MS7 (7.0.0~beta1) I've tried to do some GetFeatures queries with a "date" type but it crashes systematically.
The sended SQL query (to Postgres 9.1, PostGIS 1.5) is not well formed :-/

The datatype

...
<element name="date_validation" minOccurs="0" type="date"/>
...

The GetFeature request

http://myserv.com/mapserv?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=my_layer&Filter=<Filter><PropertyIsLessThan><PropertyName>date_validation</PropertyName><Literal>2015-05-28T00:00:00</Literal></PropertyIsLessThan></Filter>

The response

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
<ServiceException code="NoApplicableCode" locator="mapserv">
msWFSGetFeature(): WFS server error. FLTApplyFilterToLayer() failed msPostGISLayerWhichShapes(): Query error. Error executing query. Check server logs
</ServiceException>
</ServiceExceptionReport>

The corresponding Postgres logs

...WHERE (("date_validation" <= 2015.000000-5.000000-29.0000000.0000000.0000000.000000))

I've tested the same request on a 6.0.1-3.2 MapServer and it works correctly.
Perhaps this issue is the same as the #5102

@sdlime
Copy link
Member

sdlime commented Jun 1, 2015

Any chance of getting a small test case? I don't think this is exactly #5102. Probably a conversion within the PostGIS driver or perhaps something specific to WFS.

@rouault
Copy link
Contributor

rouault commented Jun 1, 2015

Steve, I can reproduce with one of the msautotest mapfile :

~/mapserver/git/mapserver/msautotest/wxs$ MS_ERRORFILE=/dev/stderr MS_ERRORLEVEL=5 mapserv QUERY_STRING="map=wfs_time_postgis.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=time&FILTER=<Filter><PropertyIsLessThan><PropertyName>time</PropertyName><Literal>2015-05-28T00:00:00</Literal></PropertyIsLessThan></Filter>" 
[Mon Jun  1 17:23:35 2015].626366 msPostGISLayerWhichShapes(): Error (ERREUR:  erreur de syntaxe sur ou près de « .0000000 »
LINE 1: ...26) and (("time" < 2015.000000-5.000000-28.0000000.0000000.0...
                                                             ^
) executing query: select "gid","time_str","id","time",encode(AsEWKB(("the_geom"),'NDR'),'hex') as geom,"gid" from (select * from pattern1 order by gid) as foo where the_geom && ST_GeomFromText('POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))',4326) and (("time" < 2015.000000-5.000000-28.0000000.0000000.0000000.000000))
[Mon Jun  1 17:23:35 2015].626447 msPostGISLayerWhichShapes(): Query error. Error executing query. Check server logs
[Mon Jun  1 17:23:35 2015].626470 msWFSGetFeature(): WFS server error. FLTApplyFilterToLayer() failed
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" ?>
<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
  <ServiceException code="NoApplicableCode" locator="mapserv">
msWFSGetFeature(): WFS server error. FLTApplyFilterToLayer() failed
msPostGISLayerWhichShapes(): Query error. Error executing query. Check server logs
  </ServiceException>
</ServiceExceptionReport>

@rouault
Copy link
Contributor

rouault commented Jun 1, 2015

@sdlime Seems that the 2015 in "2015-05-28T00:00:00" is parsed as MS_TOKEN_LITERAL_NUMBER and not MS_TOKEN_LITERAL_TIME. Must come from the expression overhaul

rouault added a commit to rouault/mapserver that referenced this issue Jun 1, 2015
rouault added a commit to MapServer/msautotest_DEPRECATED that referenced this issue Jun 1, 2015
rouault added a commit to MapServer/msautotest_DEPRECATED that referenced this issue Jun 1, 2015
@sdlime
Copy link
Member

sdlime commented Jun 1, 2015

@ger-benjamin can you give @rouault's fix a spin? --Steve

@ger-benjamin
Copy link
Author

I've tested and now it works fine, thank you and thank you very much for your rapidity !
Do you think, can you, integrate these changes in the MS 7.0 release ? This would be useful.

@sdlime
Copy link
Member

sdlime commented Jun 2, 2015

@rouault's fix made it into the 7.0 branch and into master so it's good to go. Thanks for testing! --Steve

@sdlime sdlime closed this as completed Jun 2, 2015
rouault added a commit to rouault/mapserver that referenced this issue Jun 23, 2015
rouault added a commit to rouault/mapserver that referenced this issue Jun 23, 2015
rouault added a commit that referenced this issue Jun 23, 2015
rouault added a commit that referenced this issue Jun 23, 2015
@rouault
Copy link
Contributor

rouault commented Jun 23, 2015

2 above commits merged in in branch-7-0 (a2d862d and b1b97aa)

rouault added a commit to MapServer/msautotest_DEPRECATED that referenced this issue Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants