sequelize/sequelize · error · Error

Unquoting JSON is not supported by ${this.dialect.name} dial

Error message

Unquoting JSON is not supported by ${this.dialect.name} dialect.

What it means

formatUnquoteJson in the base QueryGenerator checks dialect.supports.jsonOperations first; if false it throws this message. Dialects without native JSON support (sqlite, db2, ibmi, snowflake) cannot honour json unboxing/unquoting and refuse to emit malformed SQL. Use a dialect that declares jsonOperations=true (postgres, mysql, mariadb, mssql, oracle) or compute the value in JavaScript instead.

Source

Thrown at packages/core/src/abstract-dialect/query-generator-typescript.ts:806

      return this.#internals.formatAssociationPath(piece);
    }

    if (piece instanceof DialectAwareFn) {
      return this.#internals.formatDialectAwareFn(piece, options);
    }

    throw new Error(`Unknown sequelize method ${piece.constructor.name}`);
  }

  /**
   * The goal of this method is to execute the equivalent of json_unquote for the current dialect.
   *
   * @param _arg
   * @param _options
   */
  formatUnquoteJson(_arg: Expression, _options: EscapeOptions | undefined): string {
    if (!this.dialect.supports.jsonOperations) {
      throw new Error(`Unquoting JSON is not supported by ${this.dialect.name} dialect.`);
    }

    throw new Error(`formatUnquoteJson has not been implemented in ${this.dialect.name}.`);
  }

  /**
   * @param _sqlExpression ⚠️ This is not an identifier, it's a raw SQL expression. It will be inlined in the query.
   * @param _path The JSON path, where each item is one level of the path
   * @param _unquote Whether the result should be unquoted (depending on dialect: ->> and #>> operators, json_unquote function). Defaults to `false`.
   */
  jsonPathExtractionQuery(
    _sqlExpression: string,
    _path: ReadonlyArray<number | string>,
    _unquote: boolean,
  ): string {
    if (!this.dialect.supports.jsonOperations) {
      throw new Error(`JSON Paths are not supported in ${this.dialect.name}.`);
    }

View on GitHub (pinned to 7e1deec499)

Solutions

  1. Switch to a JSON-capable dialect (postgres, mysql, mariadb, mssql, oracle).
  2. Store JSON as a TEXT column and parse it in JavaScript with JSON.parse instead of using SQL JSON operators.
  3. Branch on sequelize.dialect.supports.jsonOperations before issuing JSON queries.
  4. For sqlite, consider loading the JSON1 extension is not enough — Sequelize still gates on the dialect flag; use a different dialect.

Example fix

// before
await Model.findAll({ where: sequelize.literal("data->>'$.name' = 'x'") }); // on sqlite
// after
if (sequelize.dialect.supports.jsonOperations) {
  await Model.findAll({ where: sequelize.literal("data->>'$.name' = 'x'") });
} else {
  const rows = await Model.findAll();
  return rows.filter(r => r.data?.name === 'x');
}
Defensive patterns

Strategy: validation

Validate before calling

if (!sequelize.dialect.supports.jsonOperations) {
  throw new Error('This query requires JSON support; switch dialects or filter in JS');
}

Type guard

function dialectSupportsJson(d: AbstractDialect): boolean {
  return Boolean(d.supports.jsonOperations);
}

Prevention

When it happens

Trigger: Using sequelize.json() or a JsonPath expression with the ->> unquote behaviour on sqlite (e.g., in a test suite or an in-memory db). Running the same model against multiple dialects where one lacks JSON support. Calling qg.formatUnquoteJson directly in a custom query builder.

Common situations: Defaulting the test/staging DB to sqlite while production is postgres. Using DataTypes.JSON columns in a project that was originally sqlite-only. Migrating from mysql to db2/ibmi without auditing JSON usage.

Related errors


AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03). Data as JSON: /data/errors/b6900256f7220d81.json. Report an issue: GitHub.