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

Function isRedundantSubquery

packages/db/src/query/optimizer.ts:516–530  ·  view source on GitHub ↗

* Determines if a subquery is redundant (adds no value). * * @param query - The query to check * @returns True if the query is redundant and can be removed

(query: QueryIR)

Source from the content-addressed store, hash-verified

514 * @returns True if the query is redundant and can be removed
515 */
516function isRedundantSubquery(query: QueryIR): boolean {
517 return (
518 (!query.where || query.where.length === 0) &&
519 !query.select &&
520 (!query.groupBy || query.groupBy.length === 0) &&
521 (!query.having || query.having.length === 0) &&
522 (!query.orderBy || query.orderBy.length === 0) &&
523 (!query.join || query.join.length === 0) &&
524 query.limit === undefined &&
525 query.offset === undefined &&
526 !query.fnSelect &&
527 (!query.fnWhere || query.fnWhere.length === 0) &&
528 (!query.fnHaving || query.fnHaving.length === 0)
529 )
530}
531
532/**
533 * Step 1: Split all AND clauses recursively into separate WHERE clauses.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected