{"id":"9712b4b9d0dc3394","repo":"laravel/framework","slug":"this-database-engine-does-not-support-json-operati","errorCode":null,"errorMessage":"This database engine does not support JSON operations.","messagePattern":"This database engine does not support JSON operations\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Grammar.php","lineNumber":177,"sourceCode":"    {\n        if ($value !== '*') {\n            return '\"'.str_replace('\"', '\"\"', $value).'\"';\n        }\n\n        return $value;\n    }\n\n    /**\n     * Wrap the given JSON selector.\n     *\n     * @param  string  $value\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    protected function wrapJsonSelector($value)\n    {\n        throw new RuntimeException('This database engine does not support JSON operations.');\n    }\n\n    /**\n     * Determine if the given string is a JSON selector.\n     *\n     * @param  string  $value\n     * @return bool\n     */\n    protected function isJsonSelector($value)\n    {\n        return str_contains($value, '->');\n    }\n\n    /**\n     * Convert an array of column names into a delimited string.\n     *\n     * @param  array<\\Illuminate\\Contracts\\Database\\Query\\Expression|string>  $columns\n     * @return string","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Grammar.php#L159-L195","documentation":"Base Grammar::wrapJsonSelector() is overridden by database-specific grammars that support JSON (MySQL, Postgres, SQLite). The base implementation throws RuntimeException to signal that the configured database engine has no JSON path support, so any query using '->' JSON selectors cannot be compiled.","triggerScenarios":"Using JSON column access (e.g. whereJsonContains, -> operators, JSON casts) on a connection whose grammar does not override wrapJsonSelector (e.g. older SQL Server / sqlsrv, or a custom/unmapped driver).","commonSituations":"Running migrations or queries with JSON columns on SQL Server; switching a project from MySQL to a driver lacking JSON support; packages that assume JSON support; environment differences between dev (MySQL) and CI/other DBs.","solutions":["Switch to a database engine with JSON support (MySQL 5.7+, Postgres, SQLite) for connections using JSON columns.","Avoid JSON selectors on the unsupported engine; store the data in dedicated columns or a text column with manual (de)serialization.","Provide a custom Grammar for the engine that implements wrapJsonSelector() if you must use JSON paths.","Verify the connection's grammar actually supports JSON before issuing JSON queries (e.g. feature-detect or guard by driver name)."],"exampleFix":"// before\n// config: 'default' => env('DB_CONNECTION', 'sqlsrv')\nItem::whereJsonContains('meta->tags', 'sale')->get(); // throws on sqlsrv\n\n// after\n// switch connection to mysql in .env: DB_CONNECTION=mysql\n// or store meta as columns and query directly:\nItem::where('tag', 'sale')->get();","handlingStrategy":"validation","validationCode":"$grammar = \\DB::connection()->getQueryGrammar();\nif (! (new \\ReflectionMethod($grammar, 'wrapJsonSelector'))->getDeclaringClass()->getName() !== \\Illuminate\\Database\\Grammar::class) {\n    throw new \\RuntimeException('Driver '.get_class($grammar).' lacks JSON support.');\n}","typeGuard":"function driverSupportsJson(): bool {\n    $grammar = \\DB::connection()->getQueryGrammar();\n    return (new \\ReflectionMethod($grammar, 'wrapJsonSelector'))\n        ->getDeclaringClass()->getName() !== \\Illuminate\\Database\\Grammar::class;\n}","tryCatchPattern":"try {\n    Model::whereJsonContains('meta->tags', 'x')->get();\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'does not support JSON operations')) {\n        // fall back to scalar columns or different driver\n    }\n    throw $e;\n}","preventionTips":["Verify the DB driver supports JSON before using JSON selectors.","Avoid JSON columns on engines like older SQL Server.","Feature-detect via the connection's grammar class before issuing JSON queries."],"tags":["database","grammar","json","driver-incompatibility","query-builder"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}