Commit 6c867a0f authored by Marco Pivetta's avatar Marco Pivetta

#869 - DBAL-1293 - `DateIntervalType` should throw on invalid types

parent ae67ace8
......@@ -33,20 +33,17 @@ class DateIntervalType extends Type
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
$spec = null;
if ($value !== null) {
/** @var \DateInterval $value */
$spec = 'P'
if (null === $value) {
return null;
}
if ($value instanceof \DateInterval) {
return 'P'
. str_pad($value->y, 4, '0', STR_PAD_LEFT) . '-'
. $value->format('%M') . '-'
. $value->format('%D') . 'T'
. $value->format('%H') . ':'
. $value->format('%I') . ':'
. $value->format('%S')
;
. $value->format('%M-%DT%H:%I:%S');
}
return $spec;
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateInterval']);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment