sequelize/sequelize · error · Error
JSON Paths are not supported in ${this.dialect.name} without
Error message
JSON Paths are not supported in ${this.dialect.name} without unquoting the JSON value. What it means
MSSQL's jsonPathExtractionQuery only supports reading JSON values via JSON_VALUE (which always returns an unquoted scalar). Sequelize cannot safely produce a quoted-path query in MSSQL, so when called with unquote=false it throws rather than generate SQL that would return a quoted JSON string fragment the caller does not expect.
Source
Thrown at packages/mssql/src/query-generator-typescript.internal.ts:320
createSavepointQuery(savepointName: string): string {
return `SAVE TRANSACTION ${this.quoteIdentifier(savepointName)}`;
}
rollbackSavepointQuery(savepointName: string): string {
return `ROLLBACK TRANSACTION ${this.quoteIdentifier(savepointName)}`;
}
generateTransactionId(): string {
return randomBytes(10).toString('hex');
}
jsonPathExtractionQuery(
sqlExpression: string,
path: ReadonlyArray<number | string>,
unquote: boolean,
): string {
if (!unquote) {
throw new Error(
`JSON Paths are not supported in ${this.dialect.name} without unquoting the JSON value.`,
);
}
return `JSON_VALUE(${sqlExpression}, ${this.escape(buildJsonPath(path))})`;
}
formatUnquoteJson(arg: Expression, options?: EscapeOptions) {
return `JSON_VALUE(${this.escape(arg, options)})`;
}
versionQuery() {
// Uses string manipulation to convert the MS Maj.Min.Patch.Build to semver Maj.Min.Patch
return `DECLARE @ms_ver NVARCHAR(20);
SET @ms_ver = REVERSE(CONVERT(NVARCHAR(20), SERVERPROPERTY('ProductVersion')));
SELECT REVERSE(SUBSTRING(@ms_ver, CHARINDEX('.', @ms_ver)+1, 20)) AS 'version'`;
}
View on GitHub (pinned to 7e1deec499)
Solutions
- Use a path/getter that unquotes (the default for scalar reads) so Sequelize uses JSON_VALUE.
- If you need the raw quoted value, read the parent JSON column and navigate in JS rather than via a SQL path.
- Update Sequelize/mssql to a version where the JSON-path API enforces unquote:true for MSSQL automatically.
Defensive patterns
Strategy: validation
Validate before calling
// On MSSQL, force unquote for any JSON path read
function mssqlJsonPath(path) {
// Always read scalar via JSON_VALUE (unquoted)
return jsonPathExtractionQuery(column, path, true);
} Prevention
- Treat MSSQL JSON path reads as scalar-only (JSON_VALUE).
- Do not port PostgreSQL/SQLite JSON-path queries to MSSQL without enabling unquote.
- For full JSON nodes, read the column and parse in JS.
When it happens
Trigger: Using a JSON path operator/getter on a model attribute where the ORM internally calls jsonPathExtractionQuery with unquote=false — e.g. querying `Model.findAll({ where: { 'data.path': value } })` without unquoting, or a where on a nested JSON path that resolves to a string the caller compares as a scalar.
Common situations: Where-clauses on nested JSON properties on MSSQL; using the jsonPath feature ported from PostgreSQL/SQLite (which supports both modes) without adapting for MSSQL's JSON_VALUE-only model.
Related errors
- startTransactionQuery is not supported by the ${this.dialect
- The table hint "${hint}" is invalid or not supported by dial
- Unquoting JSON is not supported by ${this.dialect.name} dial
- formatUnquoteJson has not been implemented in ${this.dialect
- JSON Paths are not supported in ${this.dialect.name}.
AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03).
Data as JSON: /data/errors/aedaf4aefd38ff23.json.
Report an issue: GitHub.