Bug 20176 - Set biblio.datecreated to NOW if not defined
Summary: Set biblio.datecreated to NOW if not defined
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Julian Maurice
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 17258
  Show dependency treegraph
 
Reported: 2018-02-12 13:33 UTC by Julian Maurice
Modified: 2018-06-04 20:15 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined (1.75 KB, patch)
2018-02-12 13:34 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined (2.03 KB, patch)
2018-02-16 14:26 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined (2.09 KB, patch)
2018-02-16 14:47 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined (2.13 KB, patch)
2018-02-16 15:25 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2018-02-12 13:33:24 UTC
This bug is a continuation of bug 20144
Comment 1 Julian Maurice 2018-02-12 13:34:44 UTC
Created attachment 71466 [details] [review]
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined

Fix at constructor level, this issue appears in lot of places.

Fix for:
Field 'datecreated' doesn't have a default value

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 2 Julian Maurice 2018-02-12 13:38:10 UTC
There are other places where the default values are enforced in 'store' subroutine (Koha::Patron::Category for example). Why does this patch enforce a default value in 'new' subroutine ?
Comment 3 Jonathan Druart 2018-02-14 17:37:58 UTC
(In reply to Julian Maurice from comment #2)
> There are other places where the default values are enforced in 'store'
> subroutine (Koha::Patron::Category for example). Why does this patch enforce
> a default value in 'new' subroutine ?

There is no default value defined at DB level (and cannot) so ->new will explode:
DBIx::Class::Storage::DBI::_dbh_execute(): Field 'datecreated' doesn't have a default value at /home/vagrant/kohaclone/Koha/Object.pm line 124
Comment 4 Julian Maurice 2018-02-15 08:05:00 UTC
/home/vagrant/kohaclone/Koha/Object.pm line 124 is in "store" subroutine, so it is "store" that explodes, not "new", which is why I ask: why not override "store" to set default values (like it is done in others "Koha::Object"s) ?

$ perl -MKoha::Biblio -E 'Koha::Biblio->new'
# No errors

$ perl -MKoha::Biblio -E 'Koha::Biblio->new->store'
DBD::mysql::st execute failed: Field 'datecreated' doesn't have a default value [for Statement "INSERT INTO `biblio` () VALUES ()"] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.
DBIx::Class::Storage::DBI::_dbh_execute(): Field 'datecreated' doesn't have a default value at /home/koha/koha/Koha/Object.pm line 124
Comment 5 Jonathan Druart 2018-02-16 14:26:13 UTC
Created attachment 71778 [details] [review]
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined

Fix at ->store level, this issue appears in lot of places.

Fix for:
Field 'datecreated' doesn't have a default value
Comment 6 Jonathan Druart 2018-02-16 14:27:12 UTC
Yes sorry Julian, I have just re-read the commit I wrote locally yesterday to test and it did not make any senses.
Comment 7 Julian Maurice 2018-02-16 14:47:31 UTC
Created attachment 71814 [details] [review]
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined

Fix at ->store level, this issue appears in lot of places.

Fix for:
Field 'datecreated' doesn't have a default value

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 8 Nick Clemens 2018-02-16 15:25:54 UTC
Created attachment 71818 [details] [review]
Bug 20176: [sql_modes] Set biblio.datecreated to NOW if not defined

Fix at ->store level, this issue appears in lot of places.

Fix for:
Field 'datecreated' doesn't have a default value

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Jonathan Druart 2018-02-16 17:07:00 UTC
Pushed to master for 18.05, thanks to everybody involved!