Bug 12626 - SQLHelper replacement - C4::Acquisition
Summary: SQLHelper replacement - C4::Acquisition
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Yohann Dufour
QA Contact: Testopia
Depends on:
Blocks: 11385 12891
  Show dependency treegraph
Reported: 2014-07-22 10:14 UTC by Yohann Dufour
Modified: 2015-06-04 23:33 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:

Bug 12626: SQLHelper replacement - C4::Acquisition (1.83 KB, patch)
2014-07-22 11:51 UTC, Yohann Dufour
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12626: SQLHelper replacement - C4::Acquisition (1.90 KB, patch)
2014-07-25 13:04 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 12626: SQLHelper replacement - C4::Acquisition (2.55 KB, patch)
2014-07-28 09:20 UTC, Yohann Dufour
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12626: SQLHelper replacement - C4::Acquisition (2.69 KB, patch)
2014-08-07 21:45 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 12626: SQLHelper replacement - C4::Acquisition (2.84 KB, patch)
2014-08-17 09:44 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Yohann Dufour 2014-07-22 10:14:33 UTC
The module C4::Acquisition depends on module C4::SQLHelper. However, the module SQLHelper is obsolete, so the calls for InsertInTable have to be replaced by the use of the module DBIx::Class.
Comment 1 Yohann Dufour 2014-07-22 11:51:36 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2014-07-25 13:04:47 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2014-07-25 13:23:06 UTC
I got:

DBIx::Class::Row::new(): No such column 'origquantityrec' on Koha::Schema::Result::Aqorder at /home/koha/src/C4/Acquisition.pm line 1278

On creating an order via the acquisition module.
Comment 4 Yohann Dufour 2014-07-28 09:20:58 UTC Comment hidden (obsolete)
Comment 5 Bernardo Gonzalez Kriegel 2014-08-07 21:45:25 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2014-08-17 09:44:18 UTC
Created attachment 30893 [details] [review]
[PASSED QA] Bug 12626: SQLHelper replacement - C4::Acquisition

With this patch, the subroutine NewOrder uses DBIx::Class instead of C4::SQLHelper.

Test plan:
1) Apply the patch

2) Execute the unit tests by launching :
prove t/db_dependent/Acquisition.t

3) The result has to be a success without error or warning :
t/db_dependent/Acquisition.t .. ok
All tests successful.
Files=1, Tests=79,  2 wallclock secs ( 0.04 usr  0.01 sys +  1.80 cusr  0.09 csys =  1.94 CPU)
Result: PASS

4) Log in the koha intranet and create a new order in the acquition module

5) The creation has to be a success

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Test pass, new order created without problem, no koha-qa errors

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested creating a new order from a subscription, no problems found.
Passes tests and QA script.
Comment 7 Tomás Cohen Arazi 2014-08-26 18:51:38 UTC
Patch pushed to master.

Thanks Yohann!
Comment 8 Dobrica Pavlinusic 2014-09-08 15:07:22 UTC
This bug introduced regression for acquisition in acqui/neworderempty.pl.

In logs, I see error messages like:

addorder.pl: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`aqorders_items`, CONSTRAINT `aqorders_items_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE) at /srv/koha_ffzg//C4/Acquisition.pm line 1317., referer: https://koha.ffzg.hr:8443/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=54&basketno=3764&biblionumber=237202

And indeed, adding additional debug warns all over the place, it seems that code inside C4/Acquisition.pm sub NewOrder does:

my $ordernumber = $rs->create($new_order)->id;

which doesn't return ordernumber but instead empty string "" and all hell breaks loose (resulting in missing entries in aqorders_items.

My DBIC foo isn't that good, but cookbook suggest that above code is correct:


I'm puzzled and confused how to fix this.
Comment 9 Jonathan Druart 2014-09-08 15:27:28 UTC
It's quite weird, the unit tests pass!
I got the same error when I create a new order with items.
Comment 10 Jonathan Druart 2014-09-08 18:25:13 UTC
(In reply to Dobrica Pavlinusic from comment #8)

This bug 12891 for a fix.