( from: CollectionRef | QueryRef, allInputs: Record<string, KeyedStream>, collections: Record<string, Collection>, subscriptions: Record<string, CollectionSubscription>, callbacks: Record<string, LazyCollectionCallbacks>, lazySources: Set<string>, optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>, setWindowFn: (windowFn: (options: WindowOptions) => void) => void, cache: QueryCache, queryMapping: QueryMapping, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, )
| 1294 | } |
| 1295 | |
| 1296 | function processFrom( |
| 1297 | from: CollectionRef | QueryRef, |
| 1298 | allInputs: Record<string, KeyedStream>, |
| 1299 | collections: Record<string, Collection>, |
| 1300 | subscriptions: Record<string, CollectionSubscription>, |
| 1301 | callbacks: Record<string, LazyCollectionCallbacks>, |
| 1302 | lazySources: Set<string>, |
| 1303 | optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>, |
| 1304 | setWindowFn: (windowFn: (options: WindowOptions) => void) => void, |
| 1305 | cache: QueryCache, |
| 1306 | queryMapping: QueryMapping, |
| 1307 | aliasToCollectionId: Record<string, string>, |
| 1308 | aliasRemapping: Record<string, string>, |
| 1309 | sourceWhereClauses: Map<string, BasicExpression<boolean>>, |
| 1310 | ): { |
| 1311 | alias: string |
| 1312 | input: KeyedStream |
| 1313 | collectionId: string |
| 1314 | sourceIncludes: Array<SourceInclude> |
| 1315 | } { |
| 1316 | switch (from.type) { |
| 1317 | case `collectionRef`: { |
| 1318 | const input = allInputs[from.alias] |
| 1319 | if (!input) { |
| 1320 | throw new CollectionInputNotFoundError( |
| 1321 | from.alias, |
| 1322 | from.collection.id, |
| 1323 | Object.keys(allInputs), |
| 1324 | ) |
| 1325 | } |
| 1326 | aliasToCollectionId[from.alias] = from.collection.id |
| 1327 | return { |
| 1328 | alias: from.alias, |
| 1329 | input, |
| 1330 | collectionId: from.collection.id, |
| 1331 | sourceIncludes: [], |
| 1332 | } |
| 1333 | } |
| 1334 | case `queryRef`: { |
| 1335 | // Find the original query for caching purposes |
| 1336 | const originalQuery = queryMapping.get(from.query) || from.query |
| 1337 | |
| 1338 | // Recursively compile the sub-query with cache |
| 1339 | const subQueryResult = compileQuery( |
| 1340 | originalQuery, |
| 1341 | allInputs, |
| 1342 | collections, |
| 1343 | subscriptions, |
| 1344 | callbacks, |
| 1345 | lazySources, |
| 1346 | optimizableOrderByCollections, |
| 1347 | setWindowFn, |
| 1348 | cache, |
| 1349 | queryMapping, |
| 1350 | ) |
| 1351 | |
| 1352 | // Pull up alias mappings from subquery to parent scope. |
| 1353 | // This includes both the innermost alias-to-collection mappings AND |
no test coverage detected