Skip to content

Commit

Permalink
cachedb_mongodb: Fix a filtering operator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed Feb 22, 2018
1 parent d95187a commit 5d0839c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 7 additions & 7 deletions modules/cachedb_mongodb/cachedb_mongodb_dbase.c
Expand Up @@ -1762,10 +1762,10 @@ int mongo_cdb_filter_to_bson(const cdb_filter_t *filter, bson_t *cur)
init_str(&text_op, "$lte");
break;
case CDB_OP_GT:
init_str(&text_op, "$gte");
init_str(&text_op, "$gt");
break;
case CDB_OP_GE:
init_str(&text_op, "$ge");
init_str(&text_op, "$gte");
break;
default:
LM_BUG("unsupported operator: %d\n", filter->op);
Expand Down Expand Up @@ -1827,9 +1827,11 @@ int mongo_con_get_rows(cachedb_con *con, const cdb_filter_t *filter,
}
bson_append_document_end(&bson_filter, &child);

bstr = bson_as_json(&bson_filter, NULL);
LM_DBG("using filter: %s\n", bstr);
bson_free(bstr);
if (is_printable(L_DBG)) {
bstr = bson_as_json(&bson_filter, NULL);
LM_DBG("using filter: %s\n", bstr);
bson_free(bstr);
}

start_expire_timer(start, mongo_exec_threshold);
cursor = mongoc_collection_find(MONGO_COLLECTION(con), MONGOC_QUERY_NONE,
Expand All @@ -1849,8 +1851,6 @@ int mongo_con_get_rows(cachedb_con *con, const cdb_filter_t *filter,
}

res->count++;
LM_DBG("adding %p to [ %p / %p / %p / %p ]\n", &row->list,
&res->rows, res->rows.next, res->rows.next->next, res->rows.next->next->next);
list_add_tail(&row->list, &res->rows);
}

Expand Down
1 change: 0 additions & 1 deletion modules/cachedb_mongodb/cachedb_mongodb_dbase.h
Expand Up @@ -98,4 +98,3 @@ int mongo_con_set_cols(cachedb_con *con, const cdb_key_t *keys,
int mongo_con_unset_cols(cachedb_con *con, const cdb_key_t *filter_keys,
const cdb_val_t *filter_vals, const cdb_key_t *keys);
#endif /* CACHEDBMONGO_DBASE_H */

0 comments on commit 5d0839c

Please sign in to comment.