From 8fa96376eb69e21d40f49950459a3ff112ac2ba3 Mon Sep 17 00:00:00 2001 From: ufundo Date: Sat, 24 Apr 2021 15:44:19 +0100 Subject: [PATCH] Insert blank MYSQLTIMESTAMP fields as NULL rather than 0 Propose extending the behaviour for date fields to timestamp fields also. This was hinted at in the comment but maybe there was a reason not to? Fixes https://lab.civicrm.org/dev/core/-/issues/2558 for me at any rate... --- DB/DataObject.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DB/DataObject.php b/DB/DataObject.php index 31aa76822..c59656469 100644 --- a/DB/DataObject.php +++ b/DB/DataObject.php @@ -1183,9 +1183,9 @@ function insert() // CRM-14986 ends // DATE is empty... on a col. that can be null.. - // note: this may be usefull for time as well.. + // Also useful for MYSQLTIMESTAMP to stop NO_ZERO_DATE errors if (!$this->$k && - (($v & DB_DATAOBJECT_DATE) || ($v & DB_DATAOBJECT_TIME)) && + (($v & DB_DATAOBJECT_DATE) || (($v & DB_DATAOBJECT_TIME) || ($v & DB_DATAOBJECT_MYSQLTIMESTAMP))) && !($v & DB_DATAOBJECT_NOTNULL)) { $rightq .= " NULL ";