Defined in: packages/core/src/transformers/SchemaCollector.ts:39
Collects schema information (table names and resolved columns) from SelectQuery instances.
Example
const collector = new SchemaCollector((table) => ['id', 'name']);
const query = SelectQueryParser.parse('SELECT id, name FROM users');
const schemas = collector.collect(query);
Related tests: packages/core/tests/transformers/SchemaCollector.test.ts
Implements
SqlComponentVisitor
<void
>
Constructors
Constructor
new SchemaCollector(
tableColumnResolver
,allowWildcardWithoutResolver
):SchemaCollector
Defined in: packages/core/src/transformers/SchemaCollector.ts:52
Parameters
tableColumnResolver
null
| TableColumnResolver
allowWildcardWithoutResolver
boolean
= false
Returns
SchemaCollector
Methods
collect()
collect(
arg
):TableSchema
[]
Defined in: packages/core/src/transformers/SchemaCollector.ts:70
Collects schema information (table names and column names) from a SQL query structure. This method ensures that the collected schema information is unique and sorted. The resulting schemas and columns are sorted alphabetically to ensure deterministic ordering.
Parameters
arg
The SQL query structure to analyze.
Returns
analyze()
analyze(
arg
):SchemaAnalysisResult
Defined in: packages/core/src/transformers/SchemaCollector.ts:83
Analyzes schema information from a SQL query structure without throwing errors. Returns a result object containing successfully resolved schemas, unresolved columns, and error information if any issues were encountered.
Parameters
arg
The SQL query structure to analyze.
Returns
Analysis result containing schemas, unresolved columns, and success status.
visit()
visit(
arg
):void
Defined in: packages/core/src/transformers/SchemaCollector.ts:112
Main entry point for the visitor pattern. Implements the shallow visit pattern to distinguish between root and recursive visits.
This method ensures that schema information is collected uniquely and sorted. The resulting schemas and columns are sorted alphabetically to ensure deterministic ordering.
Parameters
arg
The SQL component to visit.
Returns
void