Neither loadByProperties or entityQuery are case sensitive. How to make it case sensitive? I'm using MySQL as a database but would rather have a portable solution if possible.

With LoadByProperty

$nodes = $this->entityTypeManager()
              ->loadByProperties(['field_myfield' => $value]);

With entityQuery

    $entity_ids = \Drupal::entityQuery('node')

You can, of course, build your own query as explained in this answer. But my question is specifically about using loadByProperties or entityQuery API.


1 Answer 1


It was this long issue thread, they add sensitive case support to entityQuery.

So instead of = operation you can use = BINARY or instead of LIKE you can use LIKE BINARY.
Try this:

$entity_ids = \Drupal::entityQuery('node')
  ->condition('field_myfield',$value, '= BINARY')
  • 1
    Thanks! But no luck with loadByProperties? I don't understand why the API provide entityQuery AND loadByProperties to be honest. I like API when their is one obvious way to do things. I will strictly use entityQuery in the future.
    – gagarine
    Jun 16, 2020 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.