Bug 20144: [sql_modes] Set correct value for old_issues.issue_id in tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 6 Feb 2018 13:55:15 +0000 (10:55 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Feb 2018 16:58:57 +0000 (13:58 -0300)
Fix for:
Column 'issue_id' cannot be null

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/UsageStats.t

index 0391b35..2b33165 100644 (file)
@@ -294,8 +294,8 @@ sub construct_objects_needed {
     # ---------- Add 1 old_issues
     $query = '
     INSERT INTO old_issues
-      (borrowernumber, branchcode, itemnumber)
-    VALUES (?,?,?)';
+      (issue_id, borrowernumber, branchcode, itemnumber)
+    VALUES ((select coalesce(max(issue_id), 0)+1 from issues),?,?,?)';
     $insert_sth = $dbh->prepare($query);
     $insert_sth->execute( $borrowernumber1, $branchcode, $item_number1 );
     my $issue_id1 = $dbh->last_insert_id( undef, undef, 'old_issues', undef );