Case sensitive query #6475

Closed
opened 2026-01-22 15:33:50 +01:00 by admin · 1 comment
Owner

Originally created by @VincentLanglet on GitHub (May 26, 2020).

Support Question

When writing $expr->like($x, $y) or $expr->eq($x, $y),
I'll get a query x LIKE y or x = y.

The behaviour of this query is different with the database

  • Mysql makes case insensitive queries
  • Postgres makes case sensitive queries

If I want to be sure, without knowing the database, to be case-insensitive, I can write

$expr->like($expr->lower($x), $expr->lower($y))

But what if I want to be case sensitive and I don't know in which database the query will be made ?
How can I do ? Does a doctrine feature exists ? Or would it be possible to create one ?

Originally created by @VincentLanglet on GitHub (May 26, 2020). ### Support Question When writing `$expr->like($x, $y)` or `$expr->eq($x, $y)`, I'll get a query `x LIKE y` or `x = y`. The behaviour of this query is different with the database - Mysql makes case insensitive queries - Postgres makes case sensitive queries If I want to be sure, without knowing the database, to be case-insensitive, I can write ``` $expr->like($expr->lower($x), $expr->lower($y)) ``` But what if I want to be case sensitive and I don't know in which database the query will be made ? How can I do ? Does a doctrine feature exists ? Or would it be possible to create one ?
admin closed this issue 2026-01-22 15:33:50 +01:00
Author
Owner

@beberlei commented on GitHub (May 27, 2020):

MySQL makes a query based on the charset of the column, so the creator of the schema is in full control of the behavior by creating the required schema. This can be achieved using Doctrine DBAL Schema access points, or when creating the schema through other tools.

@beberlei commented on GitHub (May 27, 2020): MySQL makes a query based on the charset of the column, so the creator of the schema is in full control of the behavior by creating the required schema. This can be achieved using Doctrine DBAL Schema access points, or when creating the schema through other tools.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6475