Regarding patch #1722112: Autocomplete for entityreference fields :
I think that patch is incomplete: it supports "CONTAINS" search only for User entityreference fields but not for user autocomplete fields

In the 3rd block:

+  // User autocomplete fields.
+  elseif (!empty($string)) {
+    $query = db_select('users', 'u');
+    $query->leftJoin('realname', 'rn', 'u.uid = rn.uid');
+    $query->fields('u', array('uid', 'name'));
+    $query->condition(db_or()
+      ->condition('rn.realname', db_like($string) . '%', 'LIKE')
+      ->condition('u.name', db_like($string) . '%', 'LIKE')
+    );

you can clearly see that the resulting query will be "abcd%" , not "%abcd%", because the "%" is only added after. While in the same patch, in the previous IF (the one handling User autocomplete fields) the query is built like this:
->condition('rn.realname', '%' . db_like($string) . '%', 'LIKE')

Comments

pbattino created an issue. See original summary.

pbattino’s picture

hass’s picture

Category: Bug report » Feature request
Status: Active » Needs review