UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

37 lines (36 loc) 1.61 kB
import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery"; /** * Options for SqlParameterBinder */ export interface SqlParameterBinderOptions { /** Whether to throw an error if a parameter value is missing (defaults to true) */ requireAllParameters?: boolean; } /** * SqlParameterBinder binds values to existing hardcoded parameters in SQL queries. * * This transformer is designed to work with SQL queries that already contain * parameter placeholders (e.g., :param_name) and bind actual values to them. * * Unlike SqlParamInjector which creates new WHERE conditions, this transformer * only sets values for parameters that already exist in the parsed SQL. */ export declare class SqlParameterBinder { private options; constructor(options?: SqlParameterBinderOptions); /** * Binds values to existing hardcoded parameters in the query. * @param query The SelectQuery to modify * @param parameterValues A record of parameter names and values to bind * @returns The modified SelectQuery with parameter values set * @throws Error when required parameters are missing values */ bind(query: SelectQuery, parameterValues: Record<string, any>): SelectQuery; /** * Convenience method to bind parameters to a SimpleSelectQuery. * @param query The SimpleSelectQuery to modify * @param parameterValues A record of parameter names and values to bind * @returns The modified SelectQuery with parameter values set */ bindToSimpleQuery(query: SimpleSelectQuery, parameterValues: Record<string, any>): SelectQuery; }