It looks like the code is written to be used with CONCAT but then uses CONCAT_WS.

When you use CONCAT_WS you specify the separator once as the first argument instead of between every argument.

Comments

emattias’s picture

Status: Active » Needs review
FileSize
637 bytes
None View
leolando.tan’s picture

This patch worked for me. I created a View the displays the User: uid, Profile: First name(Custom field created in Profile2), Profile: Last name(Custom field created in Profile2) and I added Global: Combine fields filter (exposed) and selected the Profile2 First and last name fields and it fixed the search issue.

Before the patch
(CONCAT_WS(' ', field_data_field_first_name.field_first_name_value, ' ', field_data_field_last_name.field_last_name_value) LIKE '%leo tan%')

After the patch
(CONCAT_WS(' ', field_data_field_first_name.field_first_name_value, field_data_field_last_name.field_last_name_value) LIKE '%leo tan%')

Thanks emattias!

pingwin4eg’s picture

Title: Combine fields filter adds extra spaces between between concatenated fields » Combine fields filter adds extra spaces between concatenated fields
Status: Needs review » Reviewed & tested by the community

Works here too. RTBC!

colan’s picture

We've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.

If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.

We apologize for the trouble, and appreciate your patience.

chaps2’s picture

Works for me. Fix to a very simple coder error - commit with confidence!

veroniqueg’s picture

it works for me, thanks
I submit a slightly different patch to remove lines that I think are not required after the fix

joelpittet’s picture

RTBC++

colan’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

What's the D8 status of this? We might need to create a ticket over there first.

joelpittet’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

It's assigned as the parent of this issue: https://www.drupal.org/node/2882843

Lendude’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

This is by design. And should not be fixed.

Yes, taking this out allows you to search for 'first_name last_name' construct. But that is actually one of the few cases where this is the desired outcome (and only if you order your fields right in the fields setup). In all other scenario's this can lead to false positives in your search results.

Since earlier in the code all extra spaces get stripped from the search terms, the space is the best separator, it prevents all false positives from turning up in your search results.

See the discussion here #2405907: Views combined filters add redundant separators in CONCAT_WS()

joelpittet’s picture

Status: Closed (won't fix) » Needs work

@Lendude, could we then construct a test to ensure we don't break or produce false positives?

Lendude’s picture

Status: Needs work » Needs review
FileSize
1.97 KB
1.2 KB

@joelpittet++
Very good idea! Here we go. I also added a patch that contains the change in #6 to show that this leads to false positives.

The last submitted patch, 12: 2367159-12-SHOULD_FAIL.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.