Problem/Motivation
Config entity query is a little confused about case (in)sensitivity. This code should return the 'Content' view (from the standard profile) among the results, but it doesn't.
$query = \Drupal::entityQuery('view');
$query->condition('label', 'c', 'CONTAINS');
$result = $query->execute();
debug($result);
Proposed resolution
I assume that the condition value is lowercased before doing the comparison, but the actual values that it's checked against are not.
Remaining tasks
Investigate, propose a resolution.
User interface changes
None.
API changes
Not sure.
#2068655: Entity fields do not support case sensitive queries
Comments
Comment #1
amateescu commentedThis should do it.
Comment #2
dawehner\Drupal\Core\Entity\QueryInterface::condition should document that the value is case-insensitive.
Comment #4
amateescu commentedFixed those test fails and documented the case-insensitivity aspect.
Comment #5
damiankloip commentedwhat do you think about all of this logic living in match? Then it's all in one place.
Apart from that, this looks good to me!
Comment #6
amateescu commentedI deliberately put them in separate places for performance reasons.
The condition array stays the same for the duration of the matching process, so it makes sense to update it as early as possible, while the match() method is invoked multiple times, but not for every property of the config entity, so it doesn't make sense to do the lowercase transformation on all values of the entity.
Comment #7
damiankloip commentedWe talked about this on IRC, it makes sense to do the transformation in compile() for sure.
Has tests and the rest of the code looks good , so RTBC.
chx, this should get your attention anyway :)
Comment #8
chx commentedThis will be fine. (It doesn't get my attention. I no longer monitor the RTBC queue.)
Comment #9
catchCommitted/pushed to 8.x, thanks!
Comment #10.0
(not verified) commentedUpdated wrong example.