Bug 24263: Replace borrowers.relationship with NULL when was empty string

When you create a new patron, its relationship field is populated with
an empty string when we are expecting NULL.

Otherwise the about page will display a warning about a missing/wrong
relationship in data (that is not in the syspref)

Test plan:
0/ Do not apply the patches from this bug report
1/ Create a new patron (child)
2/ Notice that relationship column in DB is set to an empty string
3/ Go to the about page, notice the invalid warning about relationship
values not in the syspref
4/ Apply DB changes and tests
5/ Execute the update DB entry
=> The value in DB is now NULL when was ""
6/ Execute the tests
=> It fails
7/ Apply the last patch
8/ Add and edit a patron (child)
=> relationship is set to NULL in DB
9/ Execute the tests
=> They pass!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-12-18 14:04:58 +01:00 committed by Martin Renvoize
parent 6dd95916e2
commit dcbf7ada6e
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 4 additions and 0 deletions

View File

@ -199,6 +199,10 @@ sub store {
$self->surname( uc($self->surname) )
if C4::Context->preference("uppercasesurnames");
$self->relationship(undef) # We do not want to store an empty string in this field
if defined $self->relationship
and $self->relationship eq "";
unless ( $self->in_storage ) { #AddMember
# Generate a valid userid/login if needed