mozilla-sensorweb / sensorthings

Node implementation of the OGC SensorThings API
Mozilla Public License 2.0
14 stars 9 forks source link

[Query Options] Comparison operator 'gt' used with $filter returns incorrect values when the value to compare with has the format 'xx.x' #218

Closed isabelrios closed 7 years ago

isabelrios commented 7 years ago

It seems that when the value to compare has this format 'xx.x' with decimals, the filter does not work and returns all values. In the example below there are two Observations with result = 12.4. Using the query: Get /Observations?$filter=result gt 20.0 both Observations are shown in the response, although their result value is lower than 20.0. It works fine if the value is '20'.

Example: Get /Observations: {"@iot.count":2,"value":[{"@iot.selfLink":"http://localhost:8080/v1.0/Observations(4)","@iot.id":"4","Datastream@iot.navigationLink":"http://localhost:8080/v1.0/Observations(4)/Datastream","FeatureOfInterest@iot.navigationLink":"http://localhost:8080/v1.0/Observations(4)/FeatureOfInterest","phenomenonTime":"2016-11-18T11:04:15.790Z","result":12.4,"resultTime":"2016-11-18T11:04:15.790Z","parameters":null},{"@iot.selfLink":"http://localhost:8080/v1.0/Observations(5)","@iot.id":"5","Datastream@iot.navigationLink":"http://localhost:8080/v1.0/Observations(5)/Datastream","FeatureOfInterest@iot.navigationLink":"http://localhost:8080/v1.0/Observations(5)/FeatureOfInterest","phenomenonTime":"2016-11-18T11:04:15.790Z","result":12.4,"resultTime":"2016-11-18T11:04:15.790Z","parameters":null}]}

Get /Observations?$filter=result gt 20.0 {"@iot.count":2,"value":[{"@iot.selfLink":"http://localhost:8080/v1.0/Observations(4)","@iot.id":"4","Datastream@iot.navigationLink":"http://localhost:8080/v1.0/Observations(4)/Datastream","FeatureOfInterest@iot.navigationLink":"http://localhost:8080/v1.0/Observations(4)/FeatureOfInterest","phenomenonTime":"2016-11-18T11:04:15.790Z","result":12.4,"resultTime":"2016-11-18T11:04:15.790Z","parameters":null},{"@iot.selfLink":"http://localhost:8080/v1.0/Observations(5)","@iot.id":"5","Datastream@iot.navigationLink":"http://localhost:8080/v1.0/Observations(5)/Datastream","FeatureOfInterest@iot.navigationLink":"http://localhost:8080/v1.0/Observations(5)/FeatureOfInterest","phenomenonTime":"2016-11-18T11:04:15.790Z","result":12.4,"resultTime":"2016-11-18T11:04:15.790Z","parameters":null}]}

albertopq commented 7 years ago

Hey @isabelrios , I just noticed there was something missing in the last commit. Could you please try this issue applying https://github.com/mozilla-sensorweb/sensorthings/pull/219 ?

Thanks!

isabelrios commented 7 years ago

Hi @albertopq, I just tried and seems to be working fine appliying that change.

Following the same example above, now this request: Get /Observations?$filter=result gt 20.0 Returns: {"@iot.count":0,"value":[]}

Thanks!

ferjm commented 7 years ago

It seems that this is working properly now, so I'm closing the issue.