From 9f647ca09418d9f4f70ff99ce60bf0d9fb608b37 Mon Sep 17 00:00:00 2001 From: Nikita Tokarchuk Date: Thu, 19 Mar 2020 00:44:48 +0100 Subject: [PATCH] Allow nil query in composer --- mongox/query/compose.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mongox/query/compose.go b/mongox/query/compose.go index fc9c6d1..afa5d3d 100644 --- a/mongox/query/compose.go +++ b/mongox/query/compose.go @@ -26,6 +26,10 @@ func Compose(filters ...interface{}) *Query { // Push applies single filter to a query func Push(q *Query, f interface{}) bool { + if f == nil { + return true + } + ok := false ok = ok || applyBson(q, f) ok = ok || applyLimit(q, f) @@ -91,9 +95,6 @@ func applyProtection(q *Query, f interface{}) bool { x = &f.X v = &f.V case *protection.Key: - if f == nil { - return false - } x = &f.X v = &f.V