MCPcopy Index your code
hub / github.com/TanStack/db / processFromClause

Function processFromClause

packages/db/src/query/compiler/index.ts:1038–1167  ·  view source on GitHub ↗

* Processes the FROM clause, handling direct collection references and subqueries. * Populates `aliasToCollectionId` and `aliasRemapping` for per-alias subscription tracking.

(
  from: CollectionRef | QueryRef | UnionFrom | UnionAll,
  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>>,
)

Source from the content-addressed store, hash-verified

1036 * Populates `aliasToCollectionId` and `aliasRemapping` for per-alias subscription tracking.
1037 */
1038function processFromClause(
1039 from: CollectionRef | QueryRef | UnionFrom | UnionAll,
1040 allInputs: Record<string, KeyedStream>,
1041 collections: Record<string, Collection>,
1042 subscriptions: Record<string, CollectionSubscription>,
1043 callbacks: Record<string, LazyCollectionCallbacks>,
1044 lazySources: Set<string>,
1045 optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>,
1046 setWindowFn: (windowFn: (options: WindowOptions) => void) => void,
1047 cache: QueryCache,
1048 queryMapping: QueryMapping,
1049 aliasToCollectionId: Record<string, string>,
1050 aliasRemapping: Record<string, string>,
1051 sourceWhereClauses: Map<string, BasicExpression<boolean>>,
1052): {
1053 alias: string
1054 pipeline: NamespacedAndKeyedStream
1055 collectionId: string
1056 sources: Record<string, KeyedStream>
1057 sourceIncludes: Array<SourceInclude>
1058 directIncludes: Array<IncludesCompilationResult>
1059 isUnionFrom: boolean
1060} {
1061 if (from.type === `unionAll`) {
1062 return processUnionAll(
1063 from,
1064 allInputs,
1065 collections,
1066 subscriptions,
1067 callbacks,
1068 lazySources,
1069 optimizableOrderByCollections,
1070 setWindowFn,
1071 cache,
1072 queryMapping,
1073 aliasToCollectionId,
1074 aliasRemapping,
1075 sourceWhereClauses,
1076 )
1077 }
1078
1079 if (from.type !== `unionFrom`) {
1080 const { alias, input, collectionId, sourceIncludes } = processFrom(
1081 from,
1082 allInputs,
1083 collections,
1084 subscriptions,
1085 callbacks,
1086 lazySources,
1087 optimizableOrderByCollections,
1088 setWindowFn,
1089 cache,
1090 queryMapping,
1091 aliasToCollectionId,
1092 aliasRemapping,
1093 sourceWhereClauses,
1094 )
1095

Callers 1

compileQueryFunction · 0.85

Calls 6

mapFunction · 0.90
processUnionAllFunction · 0.85
processFromFunction · 0.85
wrapInputWithAliasFunction · 0.85
encodeKeyForUnionBranchFunction · 0.85
pipeMethod · 0.80

Tested by

no test coverage detected