Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-26

DateTime type column can't be nullable

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-BETA2
    • Fix Version/s: 2.0.0-BETA3
    • Component/s: None
    • Labels:
      None

      Description

      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;
      }

        Activity

        Hide
        Jakub Husák added a comment -

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

        Show
        Jakub Husák added a comment - maybe there should be a null check in _gatherRowData method, before the value is passed to convertToPHPValue of any type class
        Hide
        Benjamin Eberlei added a comment -

        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)

        Show
        Benjamin Eberlei added a comment - 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)
        Hide
        Benjamin Eberlei added a comment -

        This was introduced with DBAL-22 and is now fixed

        Show
        Benjamin Eberlei added a comment - This was introduced with DBAL-22 and is now fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jakub Husák
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: