Summary: | SQL Reports - Picking only one option for each multiple selection results in wrong query | ||
---|---|---|---|
Product: | Koha | Reporter: | Pedro Amorim <pedro.amorim> |
Component: | Reports | Assignee: | Brendan Lawlor <blawlor> |
Status: | Pushed to stable --- | QA Contact: | Marcel de Rooy <m.de.rooy> |
Severity: | normal | ||
Priority: | P5 - low | CC: | andrew, blawlor, caroline.cyr-la-rose, fridolin.somers, kebliss, lucas, m.de.rooy |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
24.11.00,24.05.04
|
|
Circulation function: | |||
Bug Depends on: | 35746 | ||
Bug Blocks: | 37886 | ||
Attachments: |
Bug 37077: Fix report muti select for zero and single selections
Bug 37077: Fix report muti select for zero and single selections Bug 37077: Fix report muti select for zero and single selections Bug 37077: Fix report muti select for zero and single selections Bug 37077: Fix report muti select for zero and single selections |
Description
Pedro Amorim
2024-06-12 13:43:05 UTC
This one is my bad. Thanks Pedro! It's happening because the url query string is getting sent duplicate values when only one value is selected. Then on the perl side the duplicate param for the first select gets inserted into the query where the second param should be. The example query you wrote generates a url like this: http://localhost:8081/cgi-bin/koha/reports/guided_reports.pl?id=1¶m_name=Libraries%7Cbranches%3Ain&sql_params=CPL&sql_params=CPL¶m_name=Item+type%7Citemtypes%3Ain&sql_params=BK&sql_params=BK&op=run when it should be like this: http://localhost:8081/cgi-bin/koha/reports/guided_reports.pl?id=1¶m_name=Libraries%7Cbranches%3Ain&sql_params=CPL¶m_name=Item+type%7Citemtypes%3Ain&sql_params=BK&op=run This should be fixable in the javascript that overrides the form submission. Created attachment 167762 [details] [review] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. Created attachment 167763 [details] [review] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. Test plan: 1. Go to Reports and create a report from SQL select * from items where homebranch in <<Libraries|branches:in>> and itype in <<Item type|itemtypes:in>> 3. Run the report but pick only 1 library and 1 item type 4. Click the "Show SQL code" 5. Notice that the two parameters were filled correctly 6. Run the report again with zero selections 7. Click the "Show SQL code" 8. Notice that the '%' is used for the parameter 9. Run the report again with combinations of single, multiple and zero selections 10. confirm the SQL code is generated as you would expect. Created attachment 167765 [details] [review] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. Test plan: 1. Go to Reports and create a report from SQL select * from items where homebranch in <<Libraries|branches:in>> and itype in <<Item type|itemtypes:in>> 3. Run the report but pick only 1 library and 1 item type 4. Click the "Show SQL code" 5. Notice that the two parameters were filled correctly 6. Run the report again with zero selections 7. Click the "Show SQL code" 8. Notice that the '%' is used for the parameter 9. Run the report again with combinations of single, multiple and zero selections 10. confirm the SQL code is generated as you would expect. Created attachment 167785 [details] [review] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. Test plan: 1. Go to Reports and create a report from SQL select * from items where homebranch in <<Libraries|branches:in>> and itype in <<Item type|itemtypes:in>> 3. Run the report but pick only 1 library and 1 item type 4. Click the "Show SQL code" 5. Notice that the two parameters were filled correctly 6. Run the report again with zero selections 7. Click the "Show SQL code" 8. Notice that the '%' is used for the parameter 9. Run the report again with combinations of single, multiple and zero selections 10. confirm the SQL code is generated as you would expect. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Created attachment 169987 [details] [review] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. Test plan: 1. Go to Reports and create a report from SQL select * from items where homebranch in <<Libraries|branches:in>> and itype in <<Item type|itemtypes:in>> 3. Run the report but pick only 1 library and 1 item type 4. Click the "Show SQL code" 5. Notice that the two parameters were filled correctly 6. Run the report again with zero selections 7. Click the "Show SQL code" 8. Notice that the '%' is used for the parameter 9. Run the report again with combinations of single, multiple and zero selections 10. confirm the SQL code is generated as you would expect. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> QA Comment: It works but feels like hacking. Can understand that this is easier than rewriting the whole module ;) Hard to maintain.. (In reply to Marcel de Rooy from comment #7) > QA Comment: > It works but feels like hacking. Can understand that this is easier than > rewriting the whole module ;) Hard to maintain.. Makes me feel like maybe we should have a follow-up bug at least outlining how we could do better? Fixed typo in commit message. (muti) Pushed for 24.11! Well done everyone, thank you! Backported to 24.05.x for upcoming 24.05.04 Depends on Bug 35746 not in 23.11.x I do not change status because of "additional_work_needed" |