Skip to main content
StatementSync.prototype.setAllowBareNamedParameters - sqlite - Node documentation
method StatementSync.prototype.setAllowBareNamedParameters

Usage in Deno

import { StatementSync } from "node:sqlite";
StatementSync.prototype.setAllowBareNamedParameters(enabled: boolean): void

The names of SQLite parameters begin with a prefix character. By default,node:sqlite requires that this prefix character is present when binding parameters. However, with the exception of dollar sign character, these prefix characters also require extra quoting when used in object keys.

To improve ergonomics, this method can be used to also allow bare named parameters, which do not require the prefix character in JavaScript code. There are several caveats to be aware of when enabling bare named parameters:

  • The prefix character is still required in SQL.
  • The prefix character is still allowed in JavaScript. In fact, prefixed names will have slightly better binding performance.
  • Using ambiguous named parameters, such as $k and @k, in the same prepared statement will result in an exception as it cannot be determined how to bind a bare name.

Parameters

enabled: boolean

Enables or disables support for binding named parameters without the prefix character.

Return Type

void