tursodatabase/turso · error · Error

Unsupported parameter type: ${typeof value}

Error message

Unsupported parameter type: ${typeof value}

What it means

bindValue() accepts exactly five kinds of input: null/undefined (bound as NULL), number (int or double depending on Number.isInteger), string, and ArrayBuffer or any ArrayBuffer view (bound as BLOB). Everything else — boolean, bigint, plain objects, Date, functions — reaches the final else branch and throws 'Unsupported parameter type' with the JS typeof. The SQLite C API has no boolean or arbitrary-object storage class, so the binding refuses rather than guessing a coercion.

Source

Thrown at bindings/react-native/src/Statement.ts:118

   * @param value - Value to bind
   */
  private bindValue(position: number, value: SQLiteValue): void {
    if (value === null || value === undefined) {
      this._statement.bindPositionalNull(position);
    } else if (typeof value === 'number') {
      // Check if integer or float
      if (Number.isInteger(value)) {
        this._statement.bindPositionalInt(position, value);
      } else {
        this._statement.bindPositionalDouble(position, value);
      }
    } else if (typeof value === 'string') {
      this._statement.bindPositionalText(position, value);
    } else if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
      const buffer = value as unknown as ArrayBuffer;
      this._statement.bindPositionalBlob(position, buffer);
    } else {
      throw new Error(`Unsupported parameter type: ${typeof value}`);
    }
  }

  /**
   * Execute statement without returning rows (for INSERT, UPDATE, DELETE)
   *
   * @param params - Optional parameters to bind
   * @returns Result with changes and lastInsertRowid
   */
  async run(...params: BindParams[]): Promise<RunResult> {
    if (this._finalized) {
      throw new Error('Statement has been finalized');
    }

    if (this._execLock) {
      await this._execLock.acquire();
    }
    try {

View on GitHub (pinned to bad083fafb)

Solutions

  1. Convert before binding: booleans to 0/1, Date to ISO string or epoch number, BigInt to number (or string), objects to JSON.stringify(...)
  2. Sanitize unknown payloads through a normalize(value) function that maps every unsupported type to a supported one or throws your own descriptive error
  3. Type your bind values as SQLiteValue (null | number | string | ArrayBuffer) so TypeScript flags bad call sites at compile time

Example fix

// before
await stmt.run({ active: true, createdAt: new Date(), id: 9007199254740993n }); // throws

// after
await stmt.run({
  active: 1, // boolean -> integer
  createdAt: new Date().toISOString(), // Date -> string
  id: '9007199254740993', // BigInt -> string to keep precision
});
Defensive patterns

Strategy: type-guard

Type guard

type BindableValue = null | number | string | ArrayBuffer | ArrayBufferView;

function isBindableValue(v: unknown): v is BindableValue {
  return (
    v === null ||
    typeof v === 'number' ||
    typeof v === 'string' ||
    v instanceof ArrayBuffer ||
    ArrayBuffer.isView(v)
  ); // note: undefined also binds as NULL per bindValue()
}

function toBindable(v: unknown): BindableValue {
  if (isBindableValue(v) || v === undefined) return v as BindableValue;
  if (typeof v === 'boolean') return v ? 1 : 0;
  if (typeof v === 'bigint') return v.toString();
  if (v instanceof Date) return v.toISOString();
  return JSON.stringify(v);
}

stmt.bind(toBindable(value));

Prevention

When it happens

Trigger: `stmt.bind(true)` or `stmt.bind({ a: 1 })`; passing a Date object directly; passing a BigInt (typeof 'bigint') from a counter or ID generator; arrays nested inside a flattened parameter list; undefined nested inside an object value's sub-field after JSON parsing.

Common situations: Binding JSON API payloads or form state that contain booleans; migrating from a binding that auto-coerced booleans to 0/1; using crypto or snowflake IDs that produce BigInt; passing ISO dates as Date objects instead of strings.

Related errors


AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16). Data as JSON: /api/errors/e1bc9d57de3d3042. Report an issue: GitHub.