Bug 24640 - quotes.timestamp should default to NULL
Summary: quotes.timestamp should default to NULL
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Database (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 24584
  Show dependency treegraph
 
Reported: 2020-02-12 10:43 UTC by Jonathan Druart
Modified: 2020-11-30 21:47 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes a problem with the QOTD tool - you can now add and edit quotes again.
Version(s) released in:
20.05.00, 19.11.04, 19.05.09


Attachments
Bug 24640: Allow quotes.timestamp to be NULL (2.22 KB, patch)
2020-02-12 11:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24640: Allow quotes.timestamp to be NULL (2.27 KB, patch)
2020-02-16 19:56 UTC, David Nind
Details | Diff | Splinter Review
Bug 24640: Screenshot of input field on Firefox (9.20 KB, image/png)
2020-02-16 19:58 UTC, David Nind
Details
Bug 24640: Allow quotes.timestamp to be NULL (2.32 KB, patch)
2020-02-17 17:56 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2020-02-12 10:43:07 UTC
The quotes.timestamp column is a datetime without default value.
It would be better to have it timestamp default current_timestamp()
Comment 1 Jonathan Druart 2020-02-12 10:48:23 UTC
Wrong assumption. Actually this column is used as "last display at the OPAC". So it can be NULL.
Comment 2 Jonathan Druart 2020-02-12 11:28:18 UTC
Created attachment 98742 [details] [review]
Bug 24640: Allow quotes.timestamp to be NULL

It is broken with strict mode enable, timestamp is created without
default value.

Note that the .sql installer file init the value with NOW(), which is
wrong.

DBD::mysql::st execute failed: Field 'timestamp' doesn't have a default
value [for Statement "INSERT INTO quotes (source, text) VALUES (?, ?);"
with ParamValues: 0="poeut", 1="pouet"] at
/kohadevbox/koha/tools/quotes/quotes_ajax.pl line 49.

Test plan:
Create a new quote of the day
=> Without this patch you will get an error
Comment 3 David Nind 2020-02-16 19:56:16 UTC
Created attachment 99062 [details] [review]
Bug 24640: Allow quotes.timestamp to be NULL

It is broken with strict mode enable, timestamp is created without
default value.

Note that the .sql installer file init the value with NOW(), which is
wrong.

DBD::mysql::st execute failed: Field 'timestamp' doesn't have a default
value [for Statement "INSERT INTO quotes (source, text) VALUES (?, ?);"
with ParamValues: 0="poeut", 1="pouet"] at
/kohadevbox/koha/tools/quotes/quotes_ajax.pl line 49.

Test plan:
Create a new quote of the day
=> Without this patch you will get an error

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2020-02-16 19:58:59 UTC
Created attachment 99063 [details]
Bug 24640: Screenshot of input field on Firefox

Notes (using docker-testing-docker):
- I don't see the error mentioned, but the quote is not added to 
  the list
- Seems like you couldn't add or edit a quote from at least 18.11.x
- The styling is all wonky from at least 19.11.x on Firefox (very narrow
  height for the input boxes when adding or editing => Google Chrome or 
  Chromium is okay)(see screenshot attachment) - happy to add
  a new bug for this

Updated test plan:  
1) Try and add a quote - when you press enter nothing happens and it
   is n0t added to the list of quotes
2) Apply the patch
3) Run the database update (updatedatabase on koha-testing-docker or
   perl installer/data/mysql/updatedatabase.pl)
4) Try and add a quote - it should now be added to the list
5) Sign off!
Comment 5 Katrin Fischer 2020-02-17 17:56:51 UTC
Created attachment 99120 [details] [review]
Bug 24640: Allow quotes.timestamp to be NULL

It is broken with strict mode enable, timestamp is created without
default value.

Note that the .sql installer file init the value with NOW(), which is
wrong.

DBD::mysql::st execute failed: Field 'timestamp' doesn't have a default
value [for Statement "INSERT INTO quotes (source, text) VALUES (?, ?);"
with ParamValues: 0="poeut", 1="pouet"] at
/kohadevbox/koha/tools/quotes/quotes_ajax.pl line 49.

Test plan:
Create a new quote of the day
=> Without this patch you will get an error

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Martin Renvoize 2020-02-19 11:35:00 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 7 David Nind 2020-02-21 09:31:34 UTC
(In reply to David Nind from comment #4)

> - The styling is all wonky from at least 19.11.x on Firefox (very narrow
>   height for the input boxes when adding or editing => Google Chrome or 
>   Chromium is okay)(see screenshot attachment) - happy to add
>   a new bug for this

Bug 24702 created for this.
Comment 8 Joy Nelson 2020-03-05 01:55:09 UTC
Pushed to 19.11.x branch for 19.11.04
Comment 9 Lucas Gass 2020-03-10 22:43:56 UTC
backported to 19.05.x for 19.05.09