From c01b1828391ba95ef3366817aad739e264f46441 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Mon, 1 Jul 2019 23:46:37 -0400 Subject: [PATCH] Allow null query mods for dynamic queries --- queries/qm/query_mods.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/queries/qm/query_mods.go b/queries/qm/query_mods.go index 6fa6e2f..42e881e 100644 --- a/queries/qm/query_mods.go +++ b/queries/qm/query_mods.go @@ -8,7 +8,9 @@ type QueryMod func(q *queries.Query) // Apply the query mods to the Query object func Apply(q *queries.Query, mods ...QueryMod) { for _, mod := range mods { - mod(q) + if mod != nil { + mod(q) + } } } @@ -123,13 +125,12 @@ func From(from string) QueryMod { } } -func ForceIndex( index string) QueryMod { +func ForceIndex(index string) QueryMod { return func(q *queries.Query) { queries.SetForceIndex(q, index) } } - // Limit the number of returned rows func Limit(limit int) QueryMod { return func(q *queries.Query) {