Bugzilla – Attachment 117432 Details for
Bug 27821
sanitize_zero_date does not handle datetime
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27821: Make sanitize_zero_date support datetime and timestamp
Bug-27821-Make-sanitizezerodate-support-datetime-a.patch (text/plain), 1.40 KB, created by
Jonathan Druart
on 2021-03-01 10:14:57 UTC
(
hide
)
Description:
Bug 27821: Make sanitize_zero_date support datetime and timestamp
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-01 10:14:57 UTC
Size:
1.40 KB
patch
obsolete
>From 1b49920ddaa081567797748cbdb7e655e6a98ed1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 1 Mar 2021 11:14:32 +0100 >Subject: [PATCH] Bug 27821: Make sanitize_zero_date support datetime and > timestamp > >--- > installer/data/mysql/updatedatabase.pl | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 0cad111f93..1c5c24a653 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -23670,11 +23670,23 @@ sub CheckVersion { > > sub sanitize_zero_date { > my ( $table_name, $column_name ) = @_; >- $dbh->do(qq| >- UPDATE $table_name >- SET $column_name = NULL >- WHERE CAST($column_name AS CHAR(10)) = '0000-00-00'; >- |); >+ >+ my (undef, $datatype) = $dbh->selectrow_array(qq| >+ SHOW COLUMNS FROM $table_name WHERE Field = ?|, undef, $column_name); >+ >+ if ( $datatype eq 'date' ) { >+ $dbh->do(qq| >+ UPDATE $table_name >+ SET $column_name = NULL >+ WHERE CAST($column_name AS CHAR(10)) = '0000-00-00'; >+ |); >+ } else { >+ $dbh->do(qq| >+ UPDATE $table_name >+ SET $column_name = NULL >+ WHERE CAST($column_name AS CHAR(19)) = '0000-00-00 00:00:00'; >+ |); >+ } > } > > exit; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27821
: 117432