Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-939

schema update doesnt detect boolean type correctly

    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:
      centos 6 64, db2 luw10.5

      Description

      *edited*

      Dbal for db2 doesn't seem to be able to differentiate between a smallint and a boolean field on db2. If I make an entity which has a boolean field, it will create a table using type smallint. If I later try to update the schema, it will detect the column in the table as a small int, not a boolean. So, it will produce sql update statements to change the type from smallint to smallint, which is obviously unnecessary. I understand db2 doesn't have a boolean type, but it would be nice if dbal realized that a smallint is essentially already a dbal boolean.

      Additionally, the update statement is invalid syntax and fails, although this is probably a separate issue.

      Example entity

      Widget.php
      <?php
      /**
       * @ORM\Entity
       **/
      class Widget
      {
          /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue **/
          protected $id;
      
          /** @ORM\Column(type="boolean", nullable=false) **/
          private $isGoat;
      }
      

      orm:schema-tool:create produces:
      CREATE TABLE Widget (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, isGoat SMALLINT NOT NULL, PRIMARY KEY(id));

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

      ALTER TABLE WIDGET ALTER ISGOAT isGoat SMALLINT NOT NULL; CALL SYSPROC.ADMIN_CMD ('REORG TABLE WIDGET');

      but no column alteration is obviosuly needed.

      So in summary, smallint to boolean type mapping isn't realized, causing the update command to think it needs to change the type of the column.

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated: