Koha-clms/Koha/ILL/Backend
Tomás Cohen Arazi a5545d990d
Bug 40855: Replace raw SQL in Standard backend edititem with add_or_update_attributes
This patch refactors the edititem() method in the Standard ILL backend
to use the modern add_or_update_attributes() method instead of raw SQL
delete-all-and-recreate operations.

Problems with the old approach:
- 40+ lines of raw SQL bypassing ORM validation
- Inefficient delete-all-then-insert pattern
- Complex conditional SQL based on column existence
- Manual transaction handling and error-prone bind parameters
- Difficult to maintain and debug

Benefits of the new approach:
- Single line replaces 40+ lines of raw SQL
- Uses ORM validation and relationships
- Only updates attributes when values actually change
- Automatic backend column handling
- Consistent with other modernized Standard backend methods
- Better performance and maintainability

The refactoring:
- Removes all raw SQL queries (DELETE and INSERT statements)
- Removes manual transaction handling
- Removes conditional column existence checks
- Replaces with single add_or_update_attributes() call
- Maintains identical functionality and behavior

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t
=> SUCCESS: Tests pass! Refactoring maintains compatibility
3. Test ILL request editing in Standard backend:
   - Edit existing ILL request metadata
   - Add/modify custom fields
   - Verify attributes updated correctly
=> SUCCESS: Same functionality, cleaner implementation
4. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-23 16:21:34 -06:00
..
Standard.pm Bug 40855: Replace raw SQL in Standard backend edititem with add_or_update_attributes 2025-09-23 16:21:34 -06:00