[Koha-bugs] [Bug 7671] add a real primary key "accountlinesid" in accountlines

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Sep 5 14:06:45 CEST 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7671

--- Comment #23 from Paul Poulain <paul.poulain at biblibre.com> ---
QA comment:
This part of the code is wrong:
+    my $sthr = $dbh->prepare("SELECT max(accountlines_id) AS lastinsertid FROM
accountlines");
+    $sthr->execute();
+    my $datalastinsertid = $sthr->fetchrow_hashref;
+    $sthr->finish;
+    return $datalastinsertid->{'lastinsertid'};

=> in case 2 lines are added by 2 librarians almost at the same time, you may
get a wrong lastinsertid + this add an unneeded SQL query.

Please use 
         $rv = $dbh->last_insert_id($catalog, $schema, $table, $field);
instead


Also note that your updatedatabase misses a } (it does not compile):

     $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE
variable = 'OPACdefaultSortField' AND value = 'callnumber'");
     print "Upgrade to $DBversion done (Bug 8657 - Default sort by call number
does not work. Correcting system preference value.)\n";
     SetVersion ($DBversion);
+  <<<<< SHOULD BE A } HERE
+
+$DBversion = "XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("ALTER TABLE `accountlines` ADD `accountlines_id` INT NOT NULL
AUTO_INCREMENT PRIMARY KEY FIRST;");

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list