From 4e57b7124a1f30f87cce21e341022823c22d568e Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Fri, 4 Mar 2016 22:01:42 +0300 Subject: [PATCH] Fix alias unpacking bug in queries with $ne operator --- lib/query.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/query.coffee b/lib/query.coffee index 23137e8..5db57ac 100644 --- a/lib/query.coffee +++ b/lib/query.coffee @@ -95,10 +95,12 @@ expand = (query, aliases) -> else conditions = permute(k, v, aliases) if conditions.length > 1 - if new_query['$and']? - new_query['$and'].push({'$or' : conditions}) + new_query['$and'] ?= [] + if v?['$ne']? + for c in conditions + new_query['$and'].push(c) else - new_query['$and'] = [{'$or' : conditions}] + new_query['$and'].push({'$or' : conditions}) else common.extend(new_query, conditions[0])