Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-511

Schema\ColumnDiff incorrect with default varchar value and postgresql

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4, 2.3.4
    • Component/s: Schema Managers
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu 12.04.2 LTS
      PHP 5.3.10-1ubuntu3.6
      PostgreSQL(libpq) Version => 9.1.8

      Description

      I have a Schema\Table with a column:

      $usersTable->addColumn("lastip", "string", array("length" => 32, "default" => ""));
      

      When I use Schema\Comparator on this table I get a ColumnDiff:

      object(Doctrine\DBAL\Schema\ColumnDiff)[554]
        public 'oldColumnName' => string 'lastip' (length=6)
        public 'column' => 
          object(Doctrine\DBAL\Schema\Column)[481]
            protected '_type' => 
              object(Doctrine\DBAL\Types\StringType)[278]
            protected '_length' => int 32
            protected '_precision' => int 10
            protected '_scale' => int 0
            protected '_unsigned' => boolean false
            protected '_fixed' => boolean false
            protected '_notnull' => boolean true
            protected '_default' => string '' (length=0)
            protected '_autoincrement' => boolean false
            protected '_platformOptions' => 
              array
                empty
            protected '_columnDefinition' => null
            protected '_comment' => null
            protected '_customSchemaOptions' => 
              array
                empty
            protected '_name' => string 'lastip' (length=6)
            protected '_namespace' => null
            protected '_quoted' => boolean false
        public 'changedProperties' => 
          array
            0 => string 'default' (length=7)
        public 'fromColumn' => 
          object(Doctrine\DBAL\Schema\Column)[293]
            protected '_type' => 
              object(Doctrine\DBAL\Types\StringType)[278]
            protected '_length' => int 32
            protected '_precision' => int 10
            protected '_scale' => int 0
            protected '_unsigned' => boolean false
            protected '_fixed' => boolean false
            protected '_notnull' => boolean true
            protected '_default' => string '''::character varying' (length=21)
            protected '_autoincrement' => boolean false
            protected '_platformOptions' => 
              array
                empty
            protected '_columnDefinition' => null
            protected '_comment' => string '' (length=0)
            protected '_customSchemaOptions' => 
              array
                empty
            protected '_name' => string 'lastip' (length=6)
            protected '_namespace' => null
            protected '_quoted' => boolean false
      

      With "default" postgresql adds "::character varying" when it's a varchar.

      This gives a alter sql query:

      ALTER TABLE bolt_users ALTER lastip SET  DEFAULT ''
      

      After executing this, the next time it's the ColumnDiff again. Should the "::character varying" part be ignored by doctrine? Because then the schema will be valid.

      Using Doctrine 2.4.0-BETA1 (38b1a340c5ec7c58be1883696c1f956bed5b7f0c)

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Richard Hinkamp
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: