Bug 35672

Summary: Update and Run SQL button should save changes even if report fails to run
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: ReportsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: barbara.johnson, blawlor, bugzilla, cj.lynce, ddaghita, george, kebliss, nick
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 23824    
Bug Blocks:    

Description Andrew Fuerste-Henry 2023-12-29 17:36:29 UTC
To recreate:
- have a report that works, example "SELECT 1+1"
- edit your report to have a SQL error, example "SELECT 1 plus 1"
- click Update and Run SQL, get an error message due to SQL error
- click to edit report again, confirm none of your changes were saved
- re-edit your report to contain the SQL error
- click Update, confirm your report saves with an error

When using Update and Run, we should save the SQL even if it has an error, just as we do with the old Update button.
Comment 1 George Williams (NEKLS) 2024-01-03 17:28:59 UTC
+1
Comment 2 Barbara Johnson 2024-01-03 17:33:39 UTC
+1 as well
Comment 3 Andrew Fuerste-Henry 2024-02-28 18:39:50 UTC
This bug continues to cause me to lose work when I mistakenly click "Update and Run" while testing new queries. If my changes have introduced an error, all changes are lost. While I suppose the ultimate answer here is to get so gud at SQL that I don't make mistakes, that may take some time. I'd love to be able to use this button in the meantime.
Comment 4 Brendan Lawlor 2024-09-30 14:54:16 UTC
Is this still a bug?

I tested on main and 23.05, but I was only able to reproduce this behavior if I used the browser's back button. Even then it only displays the original query, but the updated one with the error is actually saved in the database. 

I see that a nice thing to know in case you ever wanted to revert to the query with no error, you could click the browser's back button and copy and paste the query and save it again.

After using the update and run button and getting an error, if you use the Koha interface the to return to editing the query you will see the edited query: 
- clicking on the name of the report in the breadcrumbs
- selecting edit from the edit dropdown
- using the 'return to previous page' link in the error message