UNPKG

rawsql-ts

Version:

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

41 lines (40 loc) 1.63 kB
import { CommonTable } from "../models/Clause"; import { SelectQuery } from "../models/SelectQuery"; /** * CTEInjector accepts a SelectQuery object and an array of CommonTables, * and inserts Common Table Expressions into the query. * For BinarySelectQuery, CTEs are inserted into the left query. * * Uses CTENameConflictResolver to resolve naming conflicts between CTEs. */ export declare class CTEInjector { private nameConflictResolver; private cteCollector; constructor(); /** * Inserts Common Table Expressions into a SelectQuery object. * * @param query The query to inject CTEs into * @param commonTables Array of CommonTables to be inserted * @returns A new query with the injected CTEs */ inject(query: SelectQuery, commonTables: CommonTable[]): SelectQuery; /** * Inserts Common Table Expressions into a SimpleSelectQuery. * * @param query The SimpleSelectQuery to inject CTEs into * @param commonTables Array of CommonTables to be inserted * @param needRecursive Boolean indicating if recursive WITH clause is needed * @returns A new SimpleSelectQuery with the injected CTEs */ private injectIntoSimpleQuery; /** * Inserts Common Table Expressions into the left query of a BinarySelectQuery. * * @param query The BinarySelectQuery to inject CTEs into * @param commonTables Array of CommonTables to be inserted * @param needRecursive Boolean indicating if recursive WITH clause is needed * @returns A new BinarySelectQuery with the injected CTEs */ private injectIntoBinaryQuery; }