Open
Description
BC Break Report
Q | A |
---|---|
BC Break | yes |
Version | 2.1 |
Summary
When we have a field with the type date if the field is updated in less than 1 second the update does not work correctly. The field is not updated
Previous behavior
In this previous version when the field was a date we compared 2 MongoDate
https://github.com/doctrine/mongodb-odm/blob/1.3.x/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L816-L823
In the MongoDate object we have a timestamp and the miliseconds.
In the new version we have https://github.com/doctrine/mongodb-odm/blob/2.6.x/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L798-L809
The UTCDateTime object contains also the milliseconds but we loose this information in the changeSet.
Is-it possible to only cast the UTCDateTime in string in order to keep this information ?
The code should be
// skip equivalent date values
if (isset($class->fieldMappings[$propName]['type']) && $class->fieldMappings[$propName]['type'] === 'date') {
/** @var DateType $dateType */
$dateType = Type::getType('date');
$dbOrgValue = $dateType->convertToDatabaseValue($orgValue);
$dbActualValue = $dateType->convertToDatabaseValue($actualValue);
$orgMillisec = $dbOrgValue instanceof UTCDateTime ? (string) $dbOrgValue : null;
$actualMillsec = $dbActualValue instanceof UTCDateTime ? (string) $dbActualValue : null;
if ($orgMillisec === $actualMillsec) {
continue;
}
}