Bug 21596: Handle empty string for other attributes when storing a patron
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 17 Oct 2018 23:01:47 +0000 (20:01 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 18 Oct 2018 14:17:40 +0000 (14:17 +0000)
lastseen, updated_on => dates
gonenoaddress, login_attempts, privacy_guarantor_checkouts => [tiny]int

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

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

Koha/Patron.pm

index 523f745..fb3f868 100644 (file)
@@ -193,9 +193,11 @@ sub store {
             $self->trim_whitespaces;
 
             # We don't want invalid dates in the db (mysql has a bad habit of inserting 0000-00-00)
-            $self->dateofbirth(undef) unless $self->dateofbirth;
-            $self->debarred(undef)    unless $self->debarred;
+            $self->dateofbirth(undef)  unless $self->dateofbirth;
+            $self->debarred(undef)     unless $self->debarred;
             $self->date_renewed(undef) unless $self->date_renewed;
+            $self->lastseen(undef)     unless $self->lastseen;
+            $self->updated_on(undef)   unless $self->updated_on;
 
             # Set default values if not set
             $self->sms_provider_id(undef) unless $self->sms_provider_id;
@@ -204,6 +206,11 @@ sub store {
             # If flags == 0 or flags == '' => no permission
             $self->flags(undef) unless $self->flags;
 
+            # tinyint or int
+            $self->gonenoaddress(0)  unless $self->gonenoaddress;
+            $self->login_attempts(0) unless $self->login_attempts;
+            $self->privacy_guarantor_checkouts(0) unless $self->privacy_guarantor_checkouts;
+
             unless ( $self->in_storage ) {    #AddMember
 
                 # Generate a valid userid/login if needed