Skip to content

Commit

Permalink
Merge pull request #1619 from FIWARE/issue/1557
Browse files Browse the repository at this point in the history
Fixed issue #1557
  • Loading branch information
kzangeli authored Jun 5, 2024
2 parents 63b517e + b23c142 commit 2c3d73c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* #1535: Ignore Subscription::q when matching subscriptions for deletion of an entity
* #1542: Array Reduction (arrays of one single element are "flattened" to that very element)
* #1551: format=simplified for distribute GET /entities gave Normalized for entities from other brokers
* #1557: Cannot count entities if geo query with $near - mongodb doesn't allow it
* #1573: pagination not working when entities have the exact same creation date (sort also by entity id)
* #1583: If a 'q' contains an ampersand, that ampersand needs to be forwarded as a semicolon
* #1593: Modify the type of an entity in a Replace operation (only working in legacy mode)
Expand Down
12 changes: 12 additions & 0 deletions src/lib/orionld/mongoc/mongocEntitiesQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,18 @@ KjNode* mongocEntitiesQuery
{
if (geoFilter(&mongoFilter, geoInfoP) == false)
return NULL;

//
// NOTE
// Counting doesn't work with $near|$nearSphere
// Must cancel the count in case it's requested, if it's a geo query with $near
//
if ((geoInfoP->georel == GeorelNear) && (countP != NULL))
{
LM_W(("Cannot count entities if georel is 'near'. MongoDB doesn't allow it"));
*countP = -2; // Mark the 'absense' of a count
countP = NULL; // This inhibits the count
}
}

bson_append_document(&options, "projection", 10, &projection);
Expand Down

0 comments on commit 2c3d73c

Please sign in to comment.