Skip to content

Commit

Permalink
Fix servicePath with q and orderBy
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan-NEC committed Jul 19, 2023
1 parent 98f7d17 commit 9e92496
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/lib/mongoBackend/MongoGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,11 @@ static std::string sortCriteria(const std::string& sortToken)
return ENT_MODIFICATION_DATE;
}

if (sortToken == SERVICE_PATH)
{
return std::string("_id.") + ENT_SERVICE_PATH;
}

if (sortToken == ENT_ENTITY_ID)
{
return std::string("_id.") + ENT_ENTITY_ID;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/rest/StringFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,10 @@ bool StringFilter::mongoFilterPopulate(std::string* errorStringP)
{
k = ENT_MODIFICATION_DATE;
}
else if (left == SERVICE_PATH)
{
k = std::string("_id.") + ENT_SERVICE_PATH;
}
else if (left == itemP->attributeName + "." + ENT_ATTRS_MD "." + NGSI_MD_DATECREATED)
{
k = std::string(ENT_ATTRS) + "." + itemP->attributeName + "." + ENT_ATTRS_CREATION_DATE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ brokerStart CB
# 04. Create entity E4 with temperature = 40 in servicePath /Barcelona/B
# 05. GET entities with q parameter and servicePath /Madrid/A
# 06. GET entities with orderBy servicePath
# 07. GET entities with orderBy !servicePath
#


Expand Down Expand Up @@ -113,6 +114,13 @@ echo
echo


echo "07. GET entities with orderBy !servicePath"
echo "=========================================="
orionCurl --url /v2/entities?orderBy=!servicePath
echo
echo


--REGEXPECT--
01. Create entity E1 with temperature = 35 in servicePath /Madrid/A
===================================================================
Expand Down Expand Up @@ -160,9 +168,28 @@ HTTP/1.1 200 OK
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Content-Type: application/json
Content-Length: 2
Content-Length: 163

[]
[
{
"id": "E1",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 35
},
"type": "T"
},
{
"id": "E3",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 30
},
"type": "T"
}
]


06. GET entities with orderBy servicePath
Expand All @@ -174,6 +201,24 @@ Content-Type: application/json
Content-Length: 325

[
{
"id": "E2",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 25
},
"type": "T"
},
{
"id": "E4",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 40
},
"type": "T"
},
{
"id": "E1",
"temperature": {
Expand All @@ -184,11 +229,32 @@ Content-Length: 325
"type": "T"
},
{
"id": "E2",
"id": "E3",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 25
"value": 30
},
"type": "T"
}
]


07. GET entities with orderBy !servicePath
==========================================
HTTP/1.1 200 OK
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Content-Type: application/json
Content-Length: 325

[
{
"id": "E1",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 35
},
"type": "T"
},
Expand All @@ -209,6 +275,15 @@ Content-Length: 325
"value": 40
},
"type": "T"
},
{
"id": "E2",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 25
},
"type": "T"
}
]

Expand Down

0 comments on commit 9e92496

Please sign in to comment.