Bug 21906

Summary: WHERE clause doesn't like % in CONCAT
Product: Koha Reporter: Christopher Brannon <cbrannon>
Component: ReportsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jonathan.druart, josef.moravec
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 9634    
Bug Blocks:    

Description Christopher Brannon 2018-11-28 20:06:47 UTC
In previous versions of Koha, I have been able to create a field that could have some information or be left blank in the WHERE clause, such as:

WHERE itemcallnumber LIKE CONCAT(<<Start of call number>>,'%')

Starting with 18.05, Koha will give me results, but it will give me blank results with the header if I download.  If I use something else, it will populate in the download just fine.  The % seems to be interfering with the download process.
Comment 1 Christopher Brannon 2018-11-28 20:22:58 UTC
More specifically, the CONCAT does not work in the download now with the % if the field is blank.  If I have anything else, it works fine, but displaying and downloading.
Comment 2 Christopher Brannon 2018-11-28 20:34:25 UTC
If I use CONCAT(IFNULL(<<Gimme>>,""),"%"), it works.  Something has changed (only with downloads) that causes the report to barf if the field is blank (null).
Comment 3 Jonathan Druart 2018-12-07 19:25:46 UTC
I have tried:
- Create a new report from SQL

SELECT itemnumber, itemcallnumber FROM items WHERE itemcallnumber LIKE CONCAT(<<Start of call number>>,'%')

- Execute
- Enter "a"
=> Return 2 results
- Export (csv, tab, ods)
=> Return 2 results

on master
Comment 4 Christopher Brannon 2018-12-07 19:48:19 UTC
(In reply to Jonathan Druart from comment #3)
> I have tried:
> - Create a new report from SQL
> 
> SELECT itemnumber, itemcallnumber FROM items WHERE itemcallnumber LIKE
> CONCAT(<<Start of call number>>,'%')
> 
> - Execute
> - Enter "a"
> => Return 2 results
> - Export (csv, tab, ods)
> => Return 2 results
> 
> on master

And what happens if you don't fill in the field?
Comment 5 Jonathan Druart 2018-12-07 20:04:43 UTC
Ha! That was the important bit indeed :)
Comment 6 Jonathan Druart 2018-12-07 20:22:30 UTC
At first glance it is caused by bug 9634.
Comment 7 Christopher Brannon 2018-12-07 20:53:42 UTC
(In reply to Jonathan Druart from comment #6)
> At first glance it is caused by bug 9634.

That would be my guess.  It broke after this was introduced.