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

[BUG] in GET /v2/entities with "q" query parameter returns wrong results #1592

Closed
iariasleon opened this issue Dec 2, 2015 · 6 comments
Closed
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

Create Requests

POST http://localhost:1026/v2/entities
Fiware-Service: qp_with_binary
Fiware-ServicePath: /test
{"id": "room_6", "my_value": 75}
POST http://localhost:1026/v2/entities
Fiware-Service: qp_with_binary
Fiware-ServicePath: /test
{"id": "room_5", "my_value": 45}

Mongo doc:

{ "_id" : { "id" : "room_5", "servicePath" : "/test" }, "attrNames" : [ "my_value" ], "attrs" : { "my_value" : { "type" : "", "creDate" : 1449084032, "modDate" : 1449084032, "value" : 45 } }, "creDate" : 1449084032, "modDate" : 1449084032 }
{ "_id" : { "id" : "room_6", "servicePath" : "/test" }, "attrNames" : [ "my_value" ], "attrs" : { "my_value" : { "type" : "", "creDate" : 1449084042, "modDate" : 1449084042, "value" : 75 } }, "creDate" : 1449084042, "modDate" : 1449084042 }

Get Request

GEThttp://localhost:1026/v2/entities?q=my_value>=
Fiware-Service: qp_with_type
Fiware-ServicePath: /test

Dataset

q=my_value>=
q=my_value>
q=my_value!=

Get Response

Status: 200 OK
[{"id":"room_5","my_value":45.000000},{"id":"room_6","my_value":75.000000}]
@iariasleon iariasleon added this to the 0.27.0 milestone Dec 2, 2015
@kzangeli
Copy link
Member

kzangeli commented Dec 2, 2015

It might be that the parser of 'q' has a stupid bug doing that >= is interpreted as BIGGER THAN '=', instead of 'BIGGER OR EQUAL TO' ...

@iariasleon
Copy link
Contributor Author

I think that if a binary expression did not have the three elements (attribute, operator and value) in that order, the parser should return an error, the same for the unary expressions, which should have two elements (operator and type or attribute) and determine if the unary operator is allowed only in front or behind or in front no matter, if so, it should be in the documentation.

@raconte
Copy link
Contributor

raconte commented Jan 22, 2016

Create entities (POST)

(curl localhost:1026/v2/entities -s -S --header Content-Type:application/json --header 'Accept: application/json' -d @- | python -mjson.tool)<< EOF
{
  "type": "Apartment",
  "id": "Floor3",
  "temperature": {
    "value": 24.4
  }
}  
EOF
(curl localhost:1026/v2/entities -s -S --header Content-Type:application/json --header 'Accept: application/json' -d @- | python -mjson.tool)<< EOF
{
  "type": "Apartment",
  "id": "Floor4",
  "temperature": {
    "value": 27.4
  }
}  
EOF

Retrieve the value. If you specified the value (GET)

(curl localhost:1026/v2/entities?q=temperature>=24.5 -s -S --header Content-Type:application/json --header 'Accept: application/json'| python -mjson.tool)

Is returned both.

Not solved

@fgalan
Copy link
Member

fgalan commented Jan 28, 2016

Fixed in PR #1735. Please @iariasleon have a look in order to check it is fixed.

@fgalan
Copy link
Member

fgalan commented Jan 29, 2016

Issue fixed in PR #1738. Please @iariasleon have check if it has been finaly solved.

@fgalan fgalan assigned iariasleon and unassigned kzangeli Jan 29, 2016
@iariasleon
Copy link
Contributor Author

LGTM

 http code: 400
 content-length: 63
 {"error":"BadRequest","description":"invalid query expression"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants