Bugzilla – Attachment 57647 Details for
Bug 17323
MySQL 5.7 - Column search_history.time cannot be null
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17323: Column search_history.time cannot be null
Bug-17323-Column-searchhistorytime-cannot-be-null.patch (text/plain), 3.58 KB, created by
Marcel de Rooy
on 2016-11-18 13:19:11 UTC
(
hide
)
Description:
Bug 17323: Column search_history.time cannot be null
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-11-18 13:19:11 UTC
Size:
3.58 KB
patch
obsolete
>From 0f39f43f0492ea3f00092546fd2b8144347995b2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 20 Sep 2016 11:40:13 +0100 >Subject: [PATCH] Bug 17323: Column search_history.time cannot be null >Content-Type: text/plain; charset=utf-8 > >When doing a search, with SearchHistory pref switched on: > >DBD::mysql::st execute failed: Column 'time' cannot be null [for Statement " > INSERT INTO search_history( > userid, sessionid, query_desc, query_cgi, type, total, time > ) VALUES( > ?, ?, ?, ?, ?, ?, ? > ) > " with ParamValues: 0="7874", 1='12338a0bd8da63e32c79ee84f8493a07', 2="kw,wrdl: d", 3='q=d', 4='biblio', 5=6104, 6=undef] at C4/Search/History.pm line 34. > >Since MySLQ 5.7, undef does not mean "the default value". >To let the DBMS set the default value (CURRENT_TIMESTAMP), the parameter should not be passed > >Test plan: >OPAC+Intranet, swith the 2 SearchHistory syspref on >Do a search >=> Without this patch, you will get an error in the log and the row will not be inserted in the table. >=> With this patch, everything must go fine > >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Not verified with MySQL 5.7. But this looks good to me. >Works under Jessie. >--- > C4/Search/History.pm | 6 +++--- > t/db_dependent/Search/History.t | 18 +++++++++++++++++- > 2 files changed, 20 insertions(+), 4 deletions(-) > >diff --git a/C4/Search/History.pm b/C4/Search/History.pm >index 53a3758..8406f30 100644 >--- a/C4/Search/History.pm >+++ b/C4/Search/History.pm >@@ -25,14 +25,14 @@ sub add { > # Add the request the user just made > my $query = q{ > INSERT INTO search_history( >- userid, sessionid, query_desc, query_cgi, type, total, time >+ userid, sessionid, query_desc, query_cgi, type, total} . ( $time ? ', time' : '' ) . q{ > ) VALUES( >- ?, ?, ?, ?, ?, ?, ? >+ ?, ?, ?, ?, ?, ?} . ( $time ? ', ?' : '' ) . q{ > ) > }; > my $sth = $dbh->prepare($query); > $sth->execute( $userid, $sessionid, $query_desc, $query_cgi, $type, >- $total, $time ); >+ $total, ( $time ? $time : () ) ); > } > > sub add_to_session { >diff --git a/t/db_dependent/Search/History.t b/t/db_dependent/Search/History.t >index 9bf14ad..27a7a73 100644 >--- a/t/db_dependent/Search/History.t >+++ b/t/db_dependent/Search/History.t >@@ -2,12 +2,13 @@ > > use Modern::Perl; > >-use Test::More tests => 25; >+use Test::More tests => 26; > use Test::Warn; > use URI::Escape; > use List::Util qw( shuffle ); > > use C4::Context; >+use Koha::DateUtils; > my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > $dbh->{RaiseError} = 1; >@@ -197,6 +198,21 @@ C4::Search::History::delete({ > $all = C4::Search::History::get({userid => $userid}); > is( scalar(@$all), 0, 'There is no search after calling delete with an interval = -1 days' ); > >+# If time is null, it must be set to NOW() >+my $query_desc_b1_p = q{first previous biblio search}; >+C4::Search::History::add( { >+ userid => $userid, >+ sessionid => $previous_sessionid, >+ query_desc => $query_desc_b1_p, >+ query_cgi => $query_cgi_b, >+ total => $total, >+ type => 'biblio', >+}); >+my $search_history_id = $dbh->last_insert_id( undef, undef, 'search_history', undef ); >+my $search_history = C4::Search::History::get({ id => $search_history_id }); >+is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string, dateonly => 1 }), "Inserting a new search history should handle undefined time" ); >+ >+ > delete_all( $userid ); > > sub add { >-- >2.1.4
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 17323
:
55715
|
55717
|
56042
| 57647