rawsql-ts
Version:
High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
34 lines (33 loc) • 1.24 kB
TypeScript
import { SelectQuery } from "../models/SelectQuery";
import { SqlParameterValue } from "../models/ValueComponent";
/**
* Represents an EXISTS / NOT EXISTS instruction derived from filter metadata.
*/
export interface ExistsInstruction {
mode: "exists" | "notExists";
anchorColumns: string[];
sql: string;
params?: Record<string, SqlParameterValue>;
}
/**
* Configuration that controls how EXISTS predicates are injected.
*/
export interface ExistsPredicateOptions {
tableColumnResolver?: (tableName: string) => string[];
strict?: boolean;
}
/**
* Describes a correlated subquery that renders an EXISTS/NOT EXISTS predicate.
*/
export interface ExistsSubqueryDefinition {
/** SQL that references the `$c#` placeholders for the anchor columns. */
sql: string;
/** Optional named parameters that the subquery requires. */
params?: Record<string, SqlParameterValue>;
}
/**
* Injects EXISTS/NOT EXISTS predicates into the provided SelectQuery.
* Each instruction is evaluated independently so failures can be skipped
* when `strict` is false.
*/
export declare function injectExistsPredicates(query: SelectQuery, instructions: ExistsInstruction[], options?: ExistsPredicateOptions): SelectQuery;