{"id":"0248a878675b5460","repo":"laravel/framework","slug":"this-database-engine-does-not-support-json-contain","errorCode":null,"errorMessage":"This database engine does not support JSON contains operations.","messagePattern":"This database engine does not support JSON contains operations\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Query/Grammars/Grammar.php","lineNumber":710,"sourceCode":"\n        return $not.$this->compileJsonContains(\n            $where['column'],\n            $this->parameter($where['value'])\n        );\n    }\n\n    /**\n     * Compile a \"JSON contains\" statement into SQL.\n     *\n     * @param  string  $column\n     * @param  string  $value\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    protected function compileJsonContains($column, $value)\n    {\n        throw new RuntimeException('This database engine does not support JSON contains operations.');\n    }\n\n    /**\n     * Compile a \"where JSON overlaps\" clause.\n     *\n     * @param  \\Illuminate\\Database\\Query\\Builder  $query\n     * @param  array  $where\n     * @return string\n     */\n    protected function whereJsonOverlaps(Builder $query, $where)\n    {\n        $not = $where['not'] ? 'not ' : '';\n\n        return $not.$this->compileJsonOverlaps(\n            $where['column'],\n            $this->parameter($where['value'])\n        );\n    }","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Query/Grammars/Grammar.php#L692-L728","documentation":"The base Grammar::compileJsonContains() throws because this engine has no JSON_CONTAINS equivalent. All four standard grammars (SQLite, MySQL, Postgres, SQL Server) override compileJsonContains, so this base throw is reached only by a custom Grammar subclass that extends Illuminate\\Database\\Query\\Grammars\\Grammar directly without implementing JSON support.","triggerScenarios":"Calling whereJsonContains($column, $value) while the connection uses a custom grammar that does not override compileJsonContains(). None of the four bundled grammars (sqlite/mysql/pgsql/sqlsrv) reach this base method.","commonSituations":"Registering a third-party or custom DB driver/grammar that extends the base Grammar without JSON methods. Forking an engine integration that has not yet implemented the JSON where-clause methods.","solutions":["Implement compileJsonContains($column, $value) on your custom Grammar using the engine's native JSON containment function.","Switch to one of the bundled connections that already supports JSON contains.","Avoid whereJsonContains and use a raw whereRaw with the engine's native JSON function."],"exampleFix":"// before (custom grammar missing impl)\nclass MyGrammar extends Grammar {}\n// calling $q->whereJsonContains('meta->tags', 'php');\n\n// after\nprotected function compileJsonContains($column, $value)\n{\n    return \"json_contains({$column}, {$value})\";\n}","handlingStrategy":"validation","validationCode":"// Only safe on bundled grammars that override compileJsonContains\n$driver = $query->getConnection()->getDriverName();\nif (! in_array($driver, ['mysql','sqlite','pgsql','sqlsrv'])) {\n    throw new \\LogicException('whereJsonContains is not supported by this engine.');\n}\n$query->whereJsonContains('meta->tags', 'php');","typeGuard":"function supportsJsonContains(\\Illuminate\\Database\\Connection $connection): bool\n{\n    return method_exists($connection->getQueryGrammar(), 'compileJsonContains');\n}","tryCatchPattern":null,"preventionTips":["Ensure custom grammars implement the full JSON where-clause family.","Add a capability test that exercises JSON methods against any new driver.","Prefer a bundled connection for JSON-heavy code."],"tags":["json","where-json-contains","custom-grammar","database-engine"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}