DBAL-511: Schema\ColumnDiff incorrect with default varchar value and postgresql #1716

Closed
doctrinebot opened this Issue May 1, 2013 · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user richardhinkamp:

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 (38b1a34)

@doctrinebot

Comment created by @beberlei:

Duplicate of DBAL-483

@doctrinebot

Comment created by richardhinkamp:

Hmm that's not a duplicate. The default column handling works great in mysql, sqlite and with integer/date/etc fields in postgres, just not with varchar and postgres. I think doctrine should handle the "::character varying" part which postgres adds to the default value of a varchar field.

@doctrinebot

Comment created by @beberlei:

Yes you are right, fixed the underlying issue now.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.3.4 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment