Laravel 13.x Adds whereBinary() for Case-Sensitive MySQL Queries
Laravel 13.x has introduced four new Query Builder methods — whereBinary(), whereNotBinary(), orWhereBinary(), and orWhereNotBinary() — to simplify case-sensitive database queries. The addition addresses a long-standing MySQL behaviour where string comparisons are case-insensitive by default, causing queries to return unintended matches across different letter cases. Previously, developers had to use raw SQL expressions such as BINARY comparisons, which reduced code readability and tied application logic to database-specific syntax. The new methods, merged via Laravel framework pull request #61261, generate binary comparison SQL under the hood while keeping the query builder syntax clean and expressive. This change is particularly useful in scenarios where exact character casing matters, such as matching usernames or tokens.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in