From e41a8833e29f470c64dfccadecc950a2bde9b24b Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 17 Mar 2017 09:14:11 +0000 Subject: [PATCH] N.701 Data Synchro: dates can be reset by the mean of an empty string (still, integers and enums cannot be reset) SVN:trunk[4596] --- core/attributedef.class.inc.php | 25 ++++++++++++++++++++++--- synchro/synchro_import.php | 9 +++++++-- synchro/synchrodatasource.class.inc.php | 13 ++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index fd48cb02a..3007d9575 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -1,5 +1,5 @@ GetCode()] = 'VARCHAR(19)'; + return $aColumns; + } + public static function GetAsUnixSeconds($value) { $oDeadlineDateTime = new DateTime($value); @@ -3837,6 +3846,8 @@ class AttributeDateTime extends AttributeDBField elseif (empty($value)) { // Make a valid date for MySQL. TO DO: support NULL as a literal value for fields that can be null. + // todo: this is NOT valid in strict mode (default setting for MySQL 5.7) + // todo: if to be kept, this should be overloaded for AttributeDate (0000-00-00) return '0000-00-00 00:00:00'; } return $value; @@ -4119,7 +4130,15 @@ class AttributeDate extends AttributeDateTime public function GetEditClass() {return "Date";} protected function GetSQLCol($bFullSpec = false) {return "DATE";} - + public function GetImportColumns() + { + // Allow an empty string to be a valid value (synonym for "reset") + $aColumns = array(); + $aColumns[$this->GetCode()] = 'VARCHAR(10)'; + return $aColumns; + } + + /** * Override to specify Field class * diff --git a/synchro/synchro_import.php b/synchro/synchro_import.php index f0779d9e8..d4cedc680 100644 --- a/synchro/synchro_import.php +++ b/synchro/synchro_import.php @@ -1,5 +1,5 @@ ToRegExpr('/'); diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index b0bf081c2..17b9b63ce 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -1,5 +1,5 @@ FromImportToValue($aData, $sExtAttCode); + if (is_null($retValue)) + { + // This is a reset + $retValue = ''; + } } return $retValue;