Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-944

db2 alter column produces invalid sql syntax

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.3, 2.3.5
    • Fix Version/s: 2.5
    • Component/s: Platforms
    • Security Level: All
    • Labels:
    • 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.

        Issue Links

          Activity

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

          A related Github Pull-Request [GH-633] was assigned:
          https://github.com/doctrine/dbal/pull/633

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-633] was assigned: https://github.com/doctrine/dbal/pull/633
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-633] was closed:
          https://github.com/doctrine/dbal/pull/633

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-633] was closed: https://github.com/doctrine/dbal/pull/633
          Hide
          Marco Pivetta added a comment -

          Fixed in DBAL-1019

          Show
          Marco Pivetta added a comment - Fixed in DBAL-1019

            People

            • Assignee:
              Marco Pivetta
              Reporter:
              chris rehfeld
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: