{"id":"b6900256f7220d81","repo":"sequelize/sequelize","slug":"unquoting-json-is-not-supported-by-this-dialect","errorCode":null,"errorMessage":"Unquoting JSON is not supported by ${this.dialect.name} dialect.","messagePattern":"Unquoting JSON is not supported by (.+?) dialect\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/abstract-dialect/query-generator-typescript.ts","lineNumber":806,"sourceCode":"      return this.#internals.formatAssociationPath(piece);\n    }\n\n    if (piece instanceof DialectAwareFn) {\n      return this.#internals.formatDialectAwareFn(piece, options);\n    }\n\n    throw new Error(`Unknown sequelize method ${piece.constructor.name}`);\n  }\n\n  /**\n   * The goal of this method is to execute the equivalent of json_unquote for the current dialect.\n   *\n   * @param _arg\n   * @param _options\n   */\n  formatUnquoteJson(_arg: Expression, _options: EscapeOptions | undefined): string {\n    if (!this.dialect.supports.jsonOperations) {\n      throw new Error(`Unquoting JSON is not supported by ${this.dialect.name} dialect.`);\n    }\n\n    throw new Error(`formatUnquoteJson has not been implemented in ${this.dialect.name}.`);\n  }\n\n  /**\n   * @param _sqlExpression ⚠️ This is not an identifier, it's a raw SQL expression. It will be inlined in the query.\n   * @param _path The JSON path, where each item is one level of the path\n   * @param _unquote Whether the result should be unquoted (depending on dialect: ->> and #>> operators, json_unquote function). Defaults to `false`.\n   */\n  jsonPathExtractionQuery(\n    _sqlExpression: string,\n    _path: ReadonlyArray<number | string>,\n    _unquote: boolean,\n  ): string {\n    if (!this.dialect.supports.jsonOperations) {\n      throw new Error(`JSON Paths are not supported in ${this.dialect.name}.`);\n    }","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/sequelize/sequelize/blob/7e1deec499d5afbb8d1877c2f4d545cead1214ec/packages/core/src/abstract-dialect/query-generator-typescript.ts#L788-L824","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Switch to a JSON-capable dialect (postgres, mysql, mariadb, mssql, oracle).","Store JSON as a TEXT column and parse it in JavaScript with JSON.parse instead of using SQL JSON operators.","Branch on sequelize.dialect.supports.jsonOperations before issuing JSON queries.","For sqlite, consider loading the JSON1 extension is not enough — Sequelize still gates on the dialect flag; use a different dialect."],"exampleFix":"// before\nawait Model.findAll({ where: sequelize.literal(\"data->>'$.name' = 'x'\") }); // on sqlite\n// after\nif (sequelize.dialect.supports.jsonOperations) {\n  await Model.findAll({ where: sequelize.literal(\"data->>'$.name' = 'x'\") });\n} else {\n  const rows = await Model.findAll();\n  return rows.filter(r => r.data?.name === 'x');\n}","handlingStrategy":"validation","validationCode":"if (!sequelize.dialect.supports.jsonOperations) {\n  throw new Error('This query requires JSON support; switch dialects or filter in JS');\n}","typeGuard":"function dialectSupportsJson(d: AbstractDialect): boolean {\n  return Boolean(d.supports.jsonOperations);\n}","tryCatchPattern":null,"preventionTips":["Default test DB to a JSON-capable dialect if production uses JSON.","Branch JSON queries behind dialect.supports.jsonOperations.","Avoid sequelize.literal() with -> / ->> operators in cross-dialect code."],"tags":["json","dialect-support","sqlite","db2","ibmi","snowflake","query-generator"],"analyzedSha":"7e1deec499d5afbb8d1877c2f4d545cead1214ec","analyzedAt":"2026-08-03T18:58:44.549Z","schemaVersion":2}