import { SqlCompiler, SqlStatement, Command } from './interfaces'; /** * SQL to MongoDB compiler implementation */ export declare class SqlCompilerImpl implements SqlCompiler { /** * Compile a SQL statement into MongoDB commands * @param statement SQL statement to compile * @returns Array of MongoDB commands */ private currentStatementMetadata; private currentTableAliases; /** * Type guard to check if an object is a From type and not a Dual type */ private isFromType; compile(statement: SqlStatement): Command[]; /** * Extract limit and offset values from an AST */ private extractLimitOffset; /** * Extract field path from a column object */ private extractFieldPath; /** * Add a field to a MongoDB projection object */ private addFieldToProjection; /** * Compile a SELECT statement into a MongoDB FIND command or AGGREGATE command */ private compileSelect; /** * Compile an INSERT statement into a MongoDB INSERT command */ private compileInsert; /** * Compile an UPDATE statement into a MongoDB UPDATE command */ private compileUpdate; /** * Handle multi-level nested fields in UPDATE SET clause * This modifies the ast.set items to properly represent deep nested paths */ private handleUpdateNestedFields; /** * Compile a DELETE statement into a MongoDB DELETE command */ private compileDelete; /** * Extract table name from FROM clause */ private extractTableName; /** * Convert SQL WHERE clause to MongoDB filter */ private convertWhere; /** * Convert SQL value to MongoDB value */ private convertValue; /** * Convert SQL columns to MongoDB projection */ private convertColumns; /** * Process a field name to handle nested fields and array indexing * Converts various formats to MongoDB dot notation: * - address.zip stays as address.zip (MongoDB supports dot notation natively) * - items__ARRAY_0__name becomes items.0.name * - items_0_name becomes items.0.name (from aggressive preprocessing) * - table.column is recognized as a nested field, not a table reference */ private processFieldName; /** * Normalizes a field path by handling various array notation formats * and returns information for further processing */ private normalizeFieldPath; /** * Get array access information from a normalized path * @deprecated Use normalizeFieldPath instead */ private getArrayAccessInfo; /** * Builds a MongoDB projection expression for array access * Handles simple and complex nested array access patterns */ private buildArrayAccessProjection; /** * Handles array access patterns at any level of nesting * This supports patterns like: * - actors.0.name * - addresses.0.details.street * - addresses.0.details.coords.0 */ private handleSimpleArrayAccess; /** * Check if a name is an actual table reference in the FROM clause * * This helps distinguish between table.column notation and nested field access */ private isActualTableReference; /** * Special handling for table references that might actually be nested fields * For example, in "SELECT address.zip FROM users", * address.zip might be parsed as table "address", column "zip" * Also handles multi-level nested references like "customer.address.city" */ private handleNestedFieldReferences; /** * Handle binary expressions that might represent multi-level nested field access * For example: customer.address.city might be parsed as a binary expression * with left=customer.address and right=city, which itself might be left=customer, right=address */ private handleNestedFieldExpressions; /** * Recursively flattens a dot-notation binary expression into a single column reference * For example, a.b.c (which is represented as (a.b).c) is flattened to a column reference "a.b.c" */ private flattenDotExpression; /** * Process WHERE clause to handle nested field references */ private processWhereClauseForNestedFields; /** * Convert SQL ORDER BY to MongoDB sort */ private convertOrderBy; /** * Convert SQL GROUP BY to MongoDB group stage */ private convertGroupBy; /** * Convert SQL JOINs to MongoDB $lookup stages */ private convertJoins; /** * Extract join conditions from the WHERE clause */ private extractJoinConditions; /** * Process a field name to figure out what the output name should be * - items__ARRAY_0__name => name * - table.column => column */ private extractOutputField; }