rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
59 lines (58 loc) • 2.17 kB
TypeScript
import { CommonTable } from "../models/Clause";
import { SqlComponent, SqlComponentVisitor } from "../models/SqlComponent";
import { ValueComponent } from "../models/ValueComponent";
import { TableColumnResolver } from "./TableColumnResolver";
/**
* A visitor that collects all SelectItem instances from a SQL query structure.
* This visitor scans through select clauses and collects all the SelectItem objects.
* It can also resolve wildcard selectors (table.* or *) using a provided table column resolver.
*/
export declare class SelectValueCollector implements SqlComponentVisitor<void> {
private handlers;
private selectValues;
private visitedNodes;
private isRootVisit;
private tableColumnResolver;
private commonTableCollector;
private commonTables;
initialCommonTables: CommonTable[] | null;
constructor(tableColumnResolver?: TableColumnResolver | null, initialCommonTables?: CommonTable[] | null);
/**
* Get all collected SelectItems as an array of objects with name and value properties
* @returns An array of objects with name (string) and value (ValueComponent) properties
*/
getValues(): {
name: string;
value: ValueComponent;
}[];
/**
* Reset the collection of SelectItems
*/
private reset;
collect(arg: SqlComponent): {
name: string;
value: ValueComponent;
}[];
/**
* Main entry point for the visitor pattern.
* Implements the shallow visit pattern to distinguish between root and recursive visits.
*/
visit(arg: SqlComponent): void;
/**
* Internal visit method used for all nodes.
* This separates the visit flag management from the actual node visitation logic.
*/
private visitNode;
/**
* Process a SimpleSelectQuery to collect data and store the current context
*/
private visitSimpleSelectQuery;
private processFromClause;
private processJoinClause;
private processSourceExpression;
private visitSelectClause;
private processSelectItem;
private visitSourceExpression;
private visitFromClause;
private addSelectValueAsUnique;
}