Skip to content
# Class: SqlParameterBinder

Defined in: packages/core/src/transformers/SqlParameterBinder.ts:23

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.

Constructors

Constructor

new SqlParameterBinder(options): SqlParameterBinder

Defined in: packages/core/src/transformers/SqlParameterBinder.ts:26

Parameters

options

SqlParameterBinderOptions = {}

Returns

SqlParameterBinder

Methods

bind()

bind(query, parameterValues): SelectQuery

Defined in: packages/core/src/transformers/SqlParameterBinder.ts:40

Binds values to existing hardcoded parameters in the query.

Parameters

query

SelectQuery

The SelectQuery to modify

parameterValues

Record<string, any&gt;

A record of parameter names and values to bind

Returns

SelectQuery

The modified SelectQuery with parameter values set

Throws

Error when required parameters are missing values


bindToSimpleQuery()

bindToSimpleQuery(query, parameterValues): SelectQuery

Defined in: packages/core/src/transformers/SqlParameterBinder.ts:86

Convenience method to bind parameters to a SimpleSelectQuery.

Parameters

query

SimpleSelectQuery

The SimpleSelectQuery to modify

parameterValues

Record<string, any&gt;

A record of parameter names and values to bind

Returns

SelectQuery

The modified SelectQuery with parameter values set

Released under the MIT License.