Skip to content
Source
Sign inSign up
TanStack/db

fix(db): preserve pushed subquery predicates #1877

MergedKyleAMathewsmerged 5 commits intomain fromrefs/pull/1877/headmerged by KyleAMathews

Showing 9 changed files with 29 additions and 14 deletions (loading 6).

x
0 of 9 viewed, 9 left
5 additions and 0 deletions.changeset/fix-subquery-predicate-compilation.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+Preserve outer predicates pushed into joined and FROM subqueries during query compilation, including when the outer and inner aliases differ.
14 additions and 9 deletionspackages/db/src/query/compiler/index.tsModified
View file
@@ -59,6 +59,7 @@
import { getLazyLoadTargets } from './lazy-targets.js'
import { processOrderBy } from './order-by.js'
import { crossJoinParentRoutes } from './parent-routes.js'
+import { queriesMatchForCaching } from './query-equivalence.js'
import {
INCLUDES_PUBLIC_KEY,
INCLUDES_ROUTING,
@@ -358,7 +359,7 @@
* @param lazySources Set of source identities that should load data lazily
* @param optimizableOrderByCollections Map of source IDs to order-by optimization info
* @param cache Optional cache for compiled subqueries (used internally for recursion)
- * @param queryMapping Optional mapping from optimized queries to original queries
+ * @param queryMapping Optional lineage from optimized queries to user-defined queries
* @returns A CompilationResult with the pipeline, source WHERE clauses, and alias metadata
export function compileQuery(
@@ -1749,12 +1750,16 @@