Skip to content

Loading…

DBAL-26: DateTime type column can't be nullable #1437

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user koubas:

After upgrade from B1 to B2 my app stopped working, throwing ConversionException on nullable DateTime field, value of which is null.
There is part of DateTimeType.php which causes it - if (!$val) matches even the valid null value.

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    $val = ($value !== null)
        ? \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value) : null;
    if (!$val) {
        throw ConversionException::conversionFailed($value, $this->getName());
    }
    return $val;
}
@doctrinebot

Comment created by koubas:

maybe there should be a null check in _gatherRowData method, before the value is passed to convertToPHPValue of any type class

@doctrinebot

Comment created by @beberlei:

This is a bug in the ConversionException code, sorry for that i will fix it tonight.

Btw, you are not using Beta2 but trunk, the ConversionException code was just committed yesterday. Additionally you should use the ORM with the Beta2 not with trunk of DBAL, they don't work together currently in some aspects (SchemaTool)

@doctrinebot

Comment created by @beberlei:

This was introduced with DBAL-22 and is now fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0.0-BETA3 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.