Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-944

db2 alter column produces invalid sql syntax

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None
    • Environment:
      db2 v10.5 centos 6.5 64

      Description

      The "alter column" sql produced is always incorrect.

      Example entity

      Widget3.php
      <?php
      /**
       * @ORM\Entity
       **/
      class Widget3
      {
          /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue **/
          protected $id;
      
          /** @ORM\Column(type="string", length=20) **/
          private $str;
      }
      

      orm:schema-tool:create produces:
      CREATE TABLE Widget3 (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, str VARCHAR(20) NOT NULL, PRIMARY KEY(id));

      If you then change the entity like so:

      Widget3.php
          /** @ORM\Column(type="string", length=100) **/
          private $str;
      }
      

      If you then run orm:schema-tool:update, it will try to run:

      ALTER TABLE WIDGET3 ALTER STR str VARCHAR(100) NOT NULL;

      which is invalid sql. It should be
      ALTER TABLE WIDGET3 ALTER COLUMN STR SET DATA TYPE VARCHAR(100);

      This renders the schema-tool inoperable in many scenarios, and causes a large portion of the db2 functional tests to fail.

        Activity

        Hide
        chris rehfeld added a comment -
        Show
        chris rehfeld added a comment - pull request https://github.com/doctrine/dbal/pull/633

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            chris rehfeld
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: