From 05e98ee6787ec8ecfd0d7617ccfcd782c55e5c4e Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Thu, 24 Feb 2022 11:54:58 -0600 Subject: [PATCH] Check "like" argument applied to keyed fields Check if queries that have a 'like' argument are applied to keyed fields. If not, log that the user is trying to use 'like' on an unsupported field type (as opposed to reporting that there are no results.) --- executor.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/executor.go b/executor.go index 7dfc994f2..e1d38b2ff 100644 --- a/executor.go +++ b/executor.go @@ -6731,6 +6731,17 @@ func (e *executor) translateCall(c *pql.Call, index string, columnKeys map[strin } } } + + // Check if "like" argument is applied to keyed fields. + if _, found := c.Args["like"].(string); found { + fieldName, err := c.FirstStringArg("_field", "field") + if err != nil || fieldName == "" { + return nil, fmt.Errorf("cannot read field name for Rows call") + } + if !idx.Field(fieldName).options.Keys { + return nil, fmt.Errorf("'%s' is not a set/mutex/time field with a string key", fieldName) + } + } } // Translate child calls.