@@ -17,10 +17,10 @@ import {
17
17
UnsupportedJoinTypeError ,
18
18
} from "../../errors.js"
19
19
import { ensureIndexForField } from "../../indexes/auto-index.js"
20
- import { PropRef } from "../ir.js"
20
+ import { PropRef , followRef } from "../ir.js"
21
21
import { inArray } from "../builder/functions.js"
22
22
import { compileExpression } from "./evaluators.js"
23
- import { compileQuery , followRef } from "./index.js"
23
+ import type { CompileQueryFn } from "./index.js"
24
24
import type { OrderByOptimizationInfo } from "./order-by.js"
25
25
import type {
26
26
BasicExpression ,
@@ -62,7 +62,8 @@ export function processJoins(
62
62
callbacks : Record < string , LazyCollectionCallbacks > ,
63
63
lazyCollections : Set < string > ,
64
64
optimizableOrderByCollections : Record < string , OrderByOptimizationInfo > ,
65
- rawQuery : QueryIR
65
+ rawQuery : QueryIR ,
66
+ onCompileSubquery : CompileQueryFn
66
67
) : NamespacedAndKeyedStream {
67
68
let resultPipeline = pipeline
68
69
@@ -81,7 +82,8 @@ export function processJoins(
81
82
callbacks ,
82
83
lazyCollections ,
83
84
optimizableOrderByCollections ,
84
- rawQuery
85
+ rawQuery ,
86
+ onCompileSubquery
85
87
)
86
88
}
87
89
@@ -105,7 +107,8 @@ function processJoin(
105
107
callbacks : Record < string , LazyCollectionCallbacks > ,
106
108
lazyCollections : Set < string > ,
107
109
optimizableOrderByCollections : Record < string , OrderByOptimizationInfo > ,
108
- rawQuery : QueryIR
110
+ rawQuery : QueryIR ,
111
+ onCompileSubquery : CompileQueryFn
109
112
) : NamespacedAndKeyedStream {
110
113
// Get the joined table alias and input stream
111
114
const {
@@ -121,7 +124,8 @@ function processJoin(
121
124
lazyCollections ,
122
125
optimizableOrderByCollections ,
123
126
cache ,
124
- queryMapping
127
+ queryMapping ,
128
+ onCompileSubquery
125
129
)
126
130
127
131
// Add the joined table to the tables map
@@ -392,7 +396,8 @@ function processJoinSource(
392
396
lazyCollections : Set < string > ,
393
397
optimizableOrderByCollections : Record < string , OrderByOptimizationInfo > ,
394
398
cache : QueryCache ,
395
- queryMapping : QueryMapping
399
+ queryMapping : QueryMapping ,
400
+ onCompileSubquery : CompileQueryFn
396
401
) : { alias : string ; input : KeyedStream ; collectionId : string } {
397
402
switch ( from . type ) {
398
403
case `collectionRef` : {
@@ -407,7 +412,7 @@ function processJoinSource(
407
412
const originalQuery = queryMapping . get ( from . query ) || from . query
408
413
409
414
// Recursively compile the sub-query with cache
410
- const subQueryResult = compileQuery (
415
+ const subQueryResult = onCompileSubquery (
411
416
originalQuery ,
412
417
allInputs ,
413
418
collections ,
0 commit comments