From 4c407c29beafd6773c151e60ffb60f3a4802e774 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 19 Sep 2016 20:41:26 -0400 Subject: [PATCH] Bug 17320: Make '0000-00-00' into 0 See comment 0. --- installer/data/mysql/updatedatabase.pl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7be9ce2..c03049b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -157,7 +157,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.00.00.006"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate='0000-00-00'"); + $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate=0"); print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n"; SetVersion ($DBversion); } @@ -1955,7 +1955,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n"; $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL "); - $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'"); + $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate=0"); SetVersion ($DBversion); } @@ -2909,7 +2909,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { # match the new type of the corresponding field $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)'); # System did not ensure budgetdate was valid historically - $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = '0000-00-00' OR budgetdate IS NULL|); + $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = 0 OR budgetdate IS NULL|); # We save the map in fundmapping in case you need later processing $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|); # these can speed processing up @@ -3632,7 +3632,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.01.00.130"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'"); + $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = 0"); print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n"; SetVersion ($DBversion); } @@ -4580,7 +4580,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $DBversion = "3.07.00.002"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { - $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';"); + $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred=0;"); print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n"; SetVersion($DBversion); } @@ -7613,7 +7613,7 @@ if ( CheckVersion($DBversion) ) { SELECT subscriptionid, startdate FROM subscription WHERE firstacquidate IS NULL - OR firstacquidate = '0000-00-00' + OR firstacquidate = 0 |); $get_subscriptions_sth->execute; while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) { @@ -10607,7 +10607,7 @@ if ( CheckVersion($DBversion) ) { $dbh->do(q| UPDATE aqorders SET orderstatus='cancelled' WHERE (datecancellationprinted IS NOT NULL OR - datecancellationprinted<>'0000-00-00'); + datecancellationprinted<>0); |); print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n"; SetVersion($DBversion); @@ -10833,16 +10833,16 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.21.00.023"; if ( CheckVersion($DBversion) ) { $dbh->do(q{ - UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00' + UPDATE borrowers SET debarred=NULL WHERE debarred=0 }); $dbh->do(q{ - UPDATE borrowers SET dateexpiry=NULL where dateexpiry='0000-00-00' + UPDATE borrowers SET dateexpiry=NULL where dateexpiry=0 }); $dbh->do(q{ - UPDATE borrowers SET dateofbirth=NULL where dateofbirth='0000-00-00' + UPDATE borrowers SET dateofbirth=NULL where dateofbirth=0 }); $dbh->do(q{ - UPDATE borrowers SET dateenrolled=NULL where dateenrolled='0000-00-00' + UPDATE borrowers SET dateenrolled=NULL where dateenrolled=0 }); print "Upgrade to $DBversion done (Bug 14717: Prevent 0000-00-00 dates in patron data)\n"; SetVersion($DBversion); -- 2.7.4