private function wrapEqualityCriteria()
{
/* If the current field has no criteria yet, do nothing. This ensures
* that we do not inadvertently inject {"$in": null} into the query.
*/
if ($this->currentField && !isset($this->query[$this->currentField]) && !array_key_exists($this->currentField, $this->query)) {
return;
}
if ($this->currentField) {
$query =& $this->query[$this->currentField];
} else {
$query =& $this->query;
}
/* If the query is an empty array, we'll assume that the user has not
* specified criteria. Otherwise, check if the array includes a query
* operator (checking the first key is sufficient). If neither of these
* conditions are met, we'll wrap the query value with $in.
*/
if (is_array($query) && (empty($query) || strpos(key($query), '$') === 0)) {
return;
}
$query = ['$in' => [$query]];
}