Bug 21610: Fix integers and dates values at Koha::Object->store level
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 18 Oct 2018 21:55:44 +0000 (18:55 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 4 Feb 2019 11:12:41 +0000 (11:12 +0000)
commit2e4883bdc57f0acd23435abed983dfccccf96f98
tree7924cf14d46d6721ffa622f786eafb0e97791e87
parentc139076372ccc8dc286a060fc0c392aba8d9c94b
Bug 21610: Fix integers and dates values at Koha::Object->store level

With strict SQL modes, we are facing several issues when objects are stored.

The following errors can be raised by DBIx::Class when an object does not have
a valid (as defined at DB level) value:
- Incorrect integer value: '' for column COLUMN
- Incorrect decimal value: '' for column COLUMN
- Column 'COLUMN' cannot be null
- Field 'COLUMN' doesn't have a default value
- Incorrect date value: '' for column 'COLUMN'

We already handled some of them for Koha::Patron. As we do not want to provide such
changes for all Koha::* modules we are going to fix this at Koha::Object->store level
in order to provide a global fix.

This is related to bug 21599 (for item types) and bug 21596 (for patrons)

Test plan:
- Apply first patch, run the tests
=> Patch fail because of the previous error in Koha::ItemType->store, to make them pass
you can replace
  $self->notforloan(0) unless $self->notforloan;
with
  $self->notforloan(undef) unless $self->notforloan;
- Apply second patch, run the tests
=> They fail because of dates and/or integers values
- Apply third patch, run the tests
=> They now pass

Deep code review wanted!

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit abb51797d8d5ebb274856e912e207a921ace478b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Object.pm