This bug is a continuation of bug 20144
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>
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 ?
(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
/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
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
Yes sorry Julian, I have just re-read the commit I wrote locally yesterday to test and it did not make any senses.
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>
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>
Pushed to master for 18.05, thanks to everybody involved!