@@ -329,6 +329,10 @@ local function build_connection_indexes(indexes, collections)
329
329
check (collections , ' collections' , ' table' )
330
330
local connection_indexes = {}
331
331
for collection_name , collection in pairs (collections ) do
332
+ assert (connection_indexes [collection_name ] == nil )
333
+ local cur_indexes = {}
334
+ connection_indexes [collection_name ] = cur_indexes
335
+
332
336
for _ , c in ipairs (collection .connections ) do
333
337
local ok = (c .destination_collection ~= nil and c .variants == nil )
334
338
or (c .destination_collection == nil and c .variants ~= nil )
@@ -339,20 +343,20 @@ local function build_connection_indexes(indexes, collections)
339
343
end
340
344
341
345
if c .destination_collection ~= nil then
342
- if connection_indexes [c .destination_collection ] == nil then
343
- connection_indexes [c .destination_collection ] = {}
346
+ if cur_indexes [c .destination_collection ] == nil then
347
+ cur_indexes [c .destination_collection ] = {}
344
348
end
345
349
validate_connection_vs_index (c , collection_name , indexes )
346
- connection_indexes [c .destination_collection ][c .name ] = {
350
+ cur_indexes [c .destination_collection ][c .name ] = {
347
351
index_name = c .index_name ,
348
352
connection_type = c .type ,
349
353
}
350
354
end
351
355
352
356
if c .variants ~= nil then
353
357
for _ , v in ipairs (c .variants ) do
354
- if connection_indexes [v .destination_collection ] == nil then
355
- connection_indexes [v .destination_collection ] = {}
358
+ if cur_indexes [v .destination_collection ] == nil then
359
+ cur_indexes [v .destination_collection ] = {}
356
360
end
357
361
local quazi_connection = {
358
362
type = c .type ,
@@ -363,7 +367,7 @@ local function build_connection_indexes(indexes, collections)
363
367
}
364
368
validate_connection_vs_index (quazi_connection ,
365
369
collection_name , indexes )
366
- connection_indexes [v .destination_collection ][c .name ] = {
370
+ cur_indexes [v .destination_collection ][c .name ] = {
367
371
index_name = v .index_name ,
368
372
connection_type = c .type ,
369
373
}
@@ -540,8 +544,9 @@ local function get_index_name(self, collection_name, from, filter, args)
540
544
-- performed by an index from the connection, then the result will be
541
545
-- postprocessed using `pivot`.
542
546
if from .collection_name ~= nil then
547
+ local cur_indexes = connection_indexes [from .collection_name ]
543
548
local connection_index =
544
- connection_indexes [collection_name ][from .connection_name ]
549
+ cur_indexes [collection_name ][from .connection_name ]
545
550
local index_name = connection_index .index_name
546
551
assert (index_name ~= nil , ' index_name must not be nil' )
547
552
-- offset in this case uses frontend filtering, so we should not set
0 commit comments