Skip to content
# Class: SchemaCollector

Defined in: packages/core/src/transformers/SchemaCollector.ts:43

Collects schema information (table names and resolved columns) from SelectQuery instances.

Example ​

typescript
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 ​

Constructors ​

Constructor ​

new SchemaCollector(tableColumnResolver, allowWildcardWithoutResolver): SchemaCollector

Defined in: packages/core/src/transformers/SchemaCollector.ts:56

Parameters ​

tableColumnResolver ​

TableColumnResolver | null

allowWildcardWithoutResolver ​

boolean = false

Returns ​

SchemaCollector

Methods ​

collect() ​

collect(arg): TableSchema[]

Defined in: packages/core/src/transformers/SchemaCollector.ts:74

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 ​

SqlComponent

The SQL query structure to analyze.

Returns ​

TableSchema[]


analyze() ​

analyze(arg): SchemaAnalysisResult

Defined in: packages/core/src/transformers/SchemaCollector.ts:87

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 ​

SqlComponent

The SQL query structure to analyze.

Returns ​

SchemaAnalysisResult

Analysis result containing schemas, unresolved columns, and success status.


visit() ​

visit(arg): void

Defined in: packages/core/src/transformers/SchemaCollector.ts:116

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 ​

SqlComponent

The SQL component to visit.

Returns ​

void

Implementation of ​

SqlComponentVisitor.visit

Released under the MIT License.