Permalink
Browse files

Fix the bug under mongo c driver v1.5

I misunderstand the interface when querying with projection
when the version of Mongo C Driver is lower than 1.5.

For reference, in case of Ubuntu 16.04, Mongo C Driver v1.3.1
will be installed, so when using 'Dedicated Bearer', v0.1.1
should be used because it does not work normally.
  • Loading branch information...
acetcom committed Oct 11, 2017
1 parent 60d228a commit 4245502ae287df9c457621b3f4cccb519c4d4878
Showing with 8 additions and 14 deletions.
  1. +8 −14 src/pcrf/pcrf_context.c
View
@@ -256,31 +256,25 @@ status_t pcrf_db_pdn_data(
mutex_lock(self.db_lock);
query = BCON_NEW(
"imsi", BCON_UTF8(imsi_bcd),
"pdn.apn", BCON_UTF8(apn));
#if MONGOC_MAJOR_VERSION >= 1 && MONGOC_MINOR_VERSION >= 5
opts = BCON_NEW(
"projection", "{",
"imsi", BCON_INT64(1),
"pdn.$", BCON_INT64(1),
"}"
);
#if MONGOC_MAJOR_VERSION >= 1 && MONGOC_MINOR_VERSION >= 5
query = BCON_NEW(
"imsi", BCON_UTF8(imsi_bcd),
"pdn.apn", BCON_UTF8(apn));
cursor = mongoc_collection_find_with_opts(
self.subscriberCollection, query, opts, NULL);
#else
query = BCON_NEW(
"$query", "{",
"imsi", BCON_UTF8(imsi_bcd),
"pdn.apn", BCON_UTF8(apn),
"}",
"$projection", "{",
"imsi", BCON_INT64(1),
"pdn.$", BCON_INT64(1),
"}"
opts = BCON_NEW(
"imsi", BCON_INT64(1),
"pdn.$", BCON_INT64(1)
);
cursor = mongoc_collection_find(self.subscriberCollection,
MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
MONGOC_QUERY_NONE, 0, 0, 0, query, opts, NULL);
#endif
if (!mongoc_cursor_next(cursor, &document))

0 comments on commit 4245502

Please sign in to comment.