UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

26 lines (25 loc) 1.04 kB
import { SelectQuery } from "../models/SelectQuery"; /** * CTENormalizer is responsible for normalizing Common Table Expressions (CTEs) within SQL queries. * It collects all CTEs from various parts of the query and consolidates them into a single WITH clause * at the root level of the query. * * This implementation uses: * 1. CommonTableCollector - to gather all CTEs from the query structure * 2. WithClauseDisabler - to remove all original WITH clauses from the query * 3. CTENameConflictResolver - to resolve name conflicts among CTEs and sort them properly */ export declare class CTENormalizer { /** * Private constructor to prevent instantiation of this utility class. */ private constructor(); /** * Normalizes a SQL query by consolidating all CTEs into a single WITH clause * at the root level of the query. * * @param query The query to normalize * @returns A new normalized query with all CTEs at the root level */ static normalize(query: SelectQuery): SelectQuery; }