Doctrine 1
  1. Doctrine 1
  2. DC-582

DataDict entry missing for datetime type for MySQL causes migrations to fail due to sql error

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 1.2.0, 1.2.1
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
      None
    • Environment:
      LAMP

      Description

      I discovered this whilst trying out migrations via symfony. I added a datetime field to my schema.yml and generated the migrations, but upon running the migration I got the following error:

      SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()' at line 1. Failing Query: "ALTER TABLE order_item ADD purchased_at datetime()"

      The following code causes the failure in the actual migration:

      $this->addColumn('order_item', 'purchased_at', 'datetime', '', array());

      because it generates the following sql:

      ALTER TABLE order_item ADD purchased_at datetime()

      The diff from my patched version which fixes the issue is as follows:

      Index: Doctrine/DataDict/Mysql.php
      ===================================================================
      — Doctrine/DataDict/Mysql.php (revision 7415)
      +++ Doctrine/DataDict/Mysql.php (working copy)
      @@ -227,6 +227,7 @@
      return 'DATE';
      case 'time':
      return 'TIME';
      + case 'datetime':
      case 'timestamp':
      return 'DATETIME';
      case 'float':

      It's against the following repository file:

      http://doctrine.mirror.svn.symfony-project.com/branches/1.2/lib/Doctrine/DataDict/Mysql.php

      I hope this is useful and gets committed

        Activity

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Rich Birch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: