laravel/framework · error · RuntimeException
This database engine does not support case sensitive like…
Error message
This database engine does not support case sensitive like operations.
What it means
The base Grammar's whereLike throws when $where['caseSensitive'] is true and the grammar does not override the method. MySQL, PostgreSQL, and SQLite all override whereLike to handle case sensitivity (e.g., MySQL uses BINARY, PostgreSQL switches between LIKE and ILIKE). SqlServerGrammar does not override it, so case-sensitive LIKE on SQL Server triggers the throw.
Solutions
- Switch to a connection whose grammar supports case-sensitive LIKE (mysql, pgsql, or sqlite)
- On SQL Server, use a raw where clause with COLLATE: ->whereRaw("[column] COLLATE Latin1_General_CS_AS LIKE ?", ['value'])
- Use where() with DB::raw() to apply an explicit case-sensitive collation per query
Example fix
// before — throws on SQL Server
User::whereLike('email', 'Admin@Example.com', caseSensitive: true)->get();
// after — raw COLLATE clause works on SQL Server
User::whereRaw("email COLLATE Latin1_General_CS_AS LIKE ?", ['Admin@Example.com'])->get(); Defensive patterns
Strategy: type-guard
Validate before calling
$driver = DB::connection()->getDriverName();
if ($driver !== 'sqlsrv') {
$query->whereLike('email', $value, caseSensitive: true);
} else {
$query->whereRaw("email COLLATE Latin1_General_CS_AS LIKE ?", [$value]);
} Type guard
function supportsCaseSensitiveLike(): bool {
return DB::connection()->getDriverName() !== 'sqlsrv';
} Try / catch
try {
$query->whereLike('email', $value, caseSensitive: true);
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'case sensitive like')) {
$query->whereRaw("email COLLATE Latin1_General_CS_AS LIKE ?", [$value]);
} else {
throw $e;
}
} Prevention
- If targeting SQL Server, avoid caseSensitive: true in whereLike calls
- Test case-sensitive LIKE queries against all target DB engines
- Keep a COLLATE clause ready as a SQL Server fallback
When it happens
Trigger: Calling ->whereLike('column', 'value', caseSensitive: true) or ->orWhereLike with caseSensitive: true on a SQL Server (sqlsrv) connection.
Common situations: Application originally developed on MySQL or PostgreSQL using case-sensitive LIKE, then migrated to SQL Server. Developer unaware that SQL Server's grammar lacks a case-sensitive LIKE override in Laravel.
Related errors
- Illegal operator and value combination.
- This database engine does not support fulltext search…
- This database engine does not support inserting while…
- A class already exists.
- A driver must be specified.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/ce4dc6b2a711a9e6.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/Query/Grammars/Grammar.php:338
*/
protected function whereBitwise(Builder $query, $where)
{
return $this->whereBasic($query, $where);
}
/**
* Compile a "where like" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*
* @throws \RuntimeException
*/
protected function whereLike(Builder $query, $where)
{
if ($where['caseSensitive']) {
throw new RuntimeException('This database engine does not support case sensitive like operations.');
}
$where['operator'] = $where['not'] ? 'not like' : 'like';
return $this->whereBasic($query, $where);
}
/**
* Compile a "where null safe equals" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereNullSafeEquals(Builder $query, $where)
{
return $this->wrap($where['column']).' is not distinct from '.$this->parameter($where['value']);
}View on GitHub (pinned to e0f6eb3518)