Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-483

default values make orm:validate-schema fail

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.4
    • Component/s: None
    • Security Level: All
    • Labels:
    • Environment:
      MySQL, PHP 5.3, Doctrine 2.3

      Description

      % ./bin/doctrine.php --env=development orm:schema-tool:update --dump-sql                                                                                                  
      ALTER TABLE groups CHANGE active active TINYINT(1) DEFAULT '1' NOT NULL;
      ALTER TABLE module ADD root_order INT DEFAULT 0 NOT NULL
      % ./bin/doctrine.php --env=development orm:schema-tool:update --force
      Updating database schema...
      Database schema updated successfully! "2" queries were executed
      % ./bin/doctrine.php --env=development orm:schema-tool:update --dump-sql                                                                                                  ALTER TABLE groups CHANGE active active TINYINT(1) DEFAULT '1' NOT NULL;
      ALTER TABLE module CHANGE root_order root_order INT DEFAULT 0 NOT NULL
      

      My entities define these columns like this:

      Group
          /**
           * @ORM\Column(name="active", type="boolean", options={"default":true})
           */
          private $active = true;
      
      Module
          /**
           * @ORM\Column(name="root_order", type="integer", options={"default":0})
           */
          private $rootOrder = 0;
      

        Activity

        Hide
        Felix Kaser added a comment -

        We are having the same issue. Is there any workaround for this?

        Show
        Felix Kaser added a comment - We are having the same issue. Is there any workaround for this?
        Hide
        Felix Kaser added a comment -

        I've investigated a bit and noticed several things:

        • looks like doctrine does not (officially?) support setting of default options in the annotation. It is recommended to use the instance default ($rootOrder = 0).
        • in the comparator class the Column->getDefault() is compared, but I found out that in one table (I guess the one from mysql) the default is set directly, in the other one (I guess the doctrine one generated from the annotations) the default is empty but the customSchemaOptions["default"] is set.

        So based on this I would say:

        • the $column->getDefault needs to be checked against the other $column->getCustomSchemaOption("default") and vice versa

        Please correct me if I'm wrong

        Show
        Felix Kaser added a comment - I've investigated a bit and noticed several things: looks like doctrine does not (officially?) support setting of default options in the annotation. It is recommended to use the instance default ($rootOrder = 0). in the comparator class the Column->getDefault() is compared, but I found out that in one table (I guess the one from mysql) the default is set directly, in the other one (I guess the doctrine one generated from the annotations) the default is empty but the customSchemaOptions ["default"] is set. So based on this I would say: the $column->getDefault needs to be checked against the other $column->getCustomSchemaOption("default") and vice versa Please correct me if I'm wrong

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Till
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: