Problem/Motivation
Hi,
i think the name_handler_filter_name_fulltext has a bug. It does not match the surname.
Steps to reproduce
- Attach a name field to a entity type
- Create a entity. Use "John Doe" as value in your name field.
- Create a view with a exposed fulltext filter.
- Search for "Doe" in your exposed filter.
- No results found.
It fails because the LIKE condition in name_handler_filter_name_fulltext::op_contains adds one additional space.
Without this patch: LIKE '% doe%'
With this patch: LIKE %doe%
Proposed resolution
Fix LIKE condition in name_handler_filter_name_fulltext::op_contains
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | extra_space_added_when-2536618-2.patch | 1.62 KB | mparker17 |
Comments
Comment #1
webflo commentedComment #2
alan d. commentedThis came up in https://drupal.org/node/1369618#comment-5542738 to ensure that search for cd didn't match abcd, but matched cdef.
produces " john doe ", so both '% doe%' and '%doe%' would match this string. Are you sure that you didn't have both first and second names in the search? ie: "%john doe%" != " john doe "
Comment #3
mparker17This looks like a duplicate of #2536618: Extra space added when searching with CONTAINS in Views Exposed Filters., except the patch in #2536618-2: Extra space added when searching with CONTAINS in Views Exposed Filters. fixes the issue in both the "contains" and the "contains word" filters.
Is it worth closing this issue, or #2536618?
Comment #4
joelpittetI'll close this as a duplicate of #2536618: Extra space added when searching with CONTAINS in Views Exposed Filters. because the other has more details and fixes the problem more completely. But I'd suggest crediting @webflo on the other one.
That or @mparker17 could you post your patches here and update the IS?
Comment #5
joelpittetThis looks like a quick fix.
Comment #6
mparker17@joelpittet, not sure I understand what you want me to do in #4... judging by your comments in #5 and your request for credit for @webflo in #2090789-5: Fulltext Filter does not match surname, is it safe for me to assume that there is nothing I need to do?
Comment #7
joelpittet@mparker17 since you replied, could you move your code here and close your issue? That would be the easiest
Comment #8
mparker17Sure thing!
Comment #9
mparker17Uploading patch from #2536618-2: Extra space added when searching with CONTAINS in Views Exposed Filters..
To make things easier to understand, I will fix
\name_handler_filter_name_fulltext::op_word()insideincludes/name_handler_filter_name_fulltext.incin a separate patch, with interdiff.Comment #10
mparker17Oh, turns out the change to
op_word()was already done: I think the diff file didn't make that clear in the hunk headings. So this is ready to go.Comment #11
joelpittetStill RTBC, thank you @mparker17, that should make it easier to credit you both.
Comment #12
alan d. commentedI just tried repeating again without issue. As per #4 above, the query generated is:
For John Doe, searching Doe, this is: ' john doe ' LIKE '% doe%' which matches, as would John.
Am I missing something here?
Comment #13
joelpittetThanks for having a look @Alan D. We'll try again without the patch, if it always concatenates all the pieces and whitespace on both ends then there shouldn't be a problem.
Comment #14
joelpittetI couldn't reproduce this with the patch removed so I think it has been fixed for us.
Comment #15
alan d. commentedThanks for checking. :)