Score:2

Join with Like in Views Plugin

kr flag

Attempting to do a join with a LIKE operand in a Views filter plugin. The query looks similar to below; however, when it executes, the LIKE operand is not taken into account and the join is done with '='. Is there a way to do this type of join?

$configuration = [
     'type' => 'INNER',
     'table' => 'path_alias',
     'field' => 'CONCAT(\'%\', path_alias.path)',
     'left_table' => 'redirect',
     'left_field' => 'redirect_redirect__uri',
     'operator' => 'LIKE',];

   $join = Views::pluginManager('join')->createInstance('standard', $configuration);
   $this->query->addRelationship('path', $join, 'path_alias');

This is the query we are trying to execute:

SELECT *
FROM redirect AS redirect
INNER JOIN path_alias AS path ON 
  redirect.redirect_redirect__uri LIKE CONCAT('%', path.path);
Score:1
kr flag

There is a patch available that provides a solution to this problem: https://www.drupal.org/project/redirect/issues/2981544.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.