Bug 11221: ensure that SQLHelper uses NULL rather than 0000-00-00 as default date...
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 12 Nov 2013 14:07:54 +0000 (15:07 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 19 Nov 2013 15:29:08 +0000 (15:29 +0000)
commitd63b4a766cc41a1cfdcb2a6eecac0782e43b63f7
treeebea06b3f4fa89ec925e9917925b6162491a7ad1
parenta1d4af3d73bacd552fa7411e29b4963c9350ea20
Bug 11221: ensure that SQLHelper uses NULL rather than 0000-00-00 as default date value

The default values for date fields is undef, so if a date field contains
an empty string, we should insert NULL in the DB, not 0000-00-00.
The format_date_in_iso routine should be only called if a date is
defined, is not equal to an empty string and does not match the iso
regex.

This patch fixes a bug where editing or creating a patron record
without setting the birth date results in 0000-00-00 rather than null
being set as the dateofbirth value.

Partial test plan:
1. Create a new patron. Leave dateofbirth empty.
2. Save the record.
3. Open the record for editing.
4. Save the record without making changes.
5. Koha gives no error.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Now when no date is given NULL is saved to the database.

Tested:
- Adding a patron without date of birth
- Editing the patron, entering a date of birth
- Editing the patron, deleting date of birth
All worked as expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/SQLHelper.pm