Bug 17323: Column search_history.time cannot be null
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 20 Sep 2016 10:40:13 +0000 (11:40 +0100)
committerMason James <mtj@kohaaloha.com>
Sat, 31 Dec 2016 02:19:46 +0000 (15:19 +1300)
commit2055454eaa016518cd0020f70347e2cd765bfe80
treeec0d0a520f01920bdf0ab7aafae06e20d99908ed
parent600663000f467252121bcdc809ffdf9bc984c065
Bug 17323: Column search_history.time cannot be null

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.
Signed-off-by: Mason James <mtj@kohaaloha.com>
C4/Search/History.pm
t/db_dependent/Search/History.t