[Koha-bugs] [Bug 17080] Koha::Object-> new should handle default values for NOT NULL columns

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Oct 14 10:14:22 CEST 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17080

Nick Clemens <nick at bywatersolutions.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #54465|0                           |1
        is obsolete|                            |
  Attachment #54466|0                           |1
        is obsolete|                            |
  Attachment #54467|0                           |1
        is obsolete|                            |
  Attachment #54468|0                           |1
        is obsolete|                            |
  Attachment #54469|0                           |1
        is obsolete|                            |

--- Comment #14 from Nick Clemens <nick at bywatersolutions.com> ---
Created attachment 56464
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=56464&action=edit
Bug 17080: Handle default values for NOT NULL columns from Koha::Object->new

Recently we face the same issue on different modules after we moved them to the
Koha namespace using Koha::Object of using DBIx::Class directly.

1/ Koha::Patron::Modification on bug 16960 comment 14 and 15
2/ Koha::Patron::Category from bug 17069
3/ C4::Members::AddMember (which does not use Koha::Object) on bug 16917

If a DB column is defined as NOT NULL and has a default value, the DBIx::Class
$rs->update_or_insert method won't use the default value if the column name
has been passed to the constructor.

We do that almost everywhere as we retrieve the data from the HTML forms
without
checking/cleaning them.

There are several ways to fix that:
1/ Continue to fix them case by case (what we did for the recent issues)
2/ Try to fix them globally (existing ones and the next ones)

This patch propose a global solution to avoid future issues of this kind.

The idea is not to pass the undefined values which cannot be nullable to the
DBIx::Class constructor.

Tested all patches together. Works as expected.
Signed-off-by: Marc Véron <veron at veron.ch>

Signed-off-by: Nick Clemens <nick at bywatersolutions.com>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list