Skip to content

Commit

Permalink
Insert blank MYSQLTIMESTAMP fields as NULL rather than 0
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
ufundo authored Apr 24, 2021
1 parent edc44b9 commit 8fa9637
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DB/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";
Expand Down

0 comments on commit 8fa9637

Please sign in to comment.