Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 9d17719

Browse files
committed
Guard get_index func from receive index_name == nil
The change is needed because we allow user to provide its own `get_index` function. Lack of index existence check can lead to an error that can be hard to debug.
1 parent 1e82d5f commit 9d17719

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

graphql/accessor_general.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,14 @@ local function select_internal(self, collection_name, from, filter, args, extra)
683683
assert(collection ~= nil,
684684
('cannot find the collection "%s"'):format(
685685
collection_name))
686+
assert(self.funcs.is_collection_exists(collection_name),
687+
('cannot find collection "%s"'):format(collection_name))
686688

687689
-- search for suitable index
688690
local full_match, index_name, index_value, pivot = get_index_name(
689691
self, collection_name, from, filter, args)
690-
assert(self.funcs.is_collection_exists(collection_name),
691-
('cannot find collection "%s"'):format(collection_name))
692-
local index = self.funcs.get_index(collection_name, index_name)
692+
local index = index_name ~= nil and
693+
self.funcs.get_index(collection_name, index_name) or nil
693694
if from.collection_name ~= 'Query' then
694695
-- allow fullscan only for a top-level object
695696
assert(index ~= nil,

0 commit comments

Comments
 (0)