* 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)
| 514 | * @returns True if the query is redundant and can be removed |
| 515 | */ |
| 516 | function 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. |
no outgoing calls
no test coverage detected