Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-226

DATETIME2 in MSSQL - declared, but not supported

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.1.6
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      From Doctrine documentation

      27. Limitations and Known Issues
      ...
      27.2.2. Microsoft SQL Server and Doctrine "datetime"
      Doctrine assumes that you use DateTime2 data-types. If your legacy database contains DateTime datatypes then you have to add your own data-type (see Basic Mapping for an example).

      In reality, the type is not supported, failing with exception

      Could not convert database value "2012-02-15 01:25:12.0000000" to Doctrine Type datetime. Expected format: Y-m-d H:i:s.u

      The reason of such behavior is a bug in DBAL
      MsSQLPlatform::getDateTimeFormatString => 'Y-m-d H:i:s.u'

      u (milliseconds in PHP) occupy 6 digits, while datetime2 type has 7 digits.
      The solution is to truncate last digit before conversion

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            ross neacoders
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: