EnumType issue after upgrade #7383

Closed
opened 2026-01-22 15:51:02 +01:00 by admin · 1 comment
Owner

Originally created by @meiyasan on GitHub (Jun 17, 2024).

Bug Report

Q A
BC Break yes
Version 3.2.0

Summary

I am investigating an issue with custom EnumType definition in MySQL.
I have defined an EnumType following Doctrine predicates quite some time ago; now that I upgraded to the last version of ORM. When I try to upgrade the database, I get a different db schema.

Current behavior

$ php bin/console doctrine:schema:update --dump-sql --force -vvv
1^ Doctrine\DBAL\Schema\ColumnDiff^ {#9492
  -oldColumn: Doctrine\DBAL\Schema\Column^ {#9471
    #_name: "action"
    #_namespace: null
    #_quoted: false
    #_type: Doctrine\DBAL\Types\StringType^ {#412}
    #_length: 0
    #_precision: null
    #_scale: 0
    #_unsigned: false
    #_fixed: false
    #_notnull: true
    #_default: null
    #_autoincrement: false
    #_platformOptions: []
    #_columnDefinition: null
    #_comment: "(DC2Type:enum,entity_action)"
  }
  -newColumn: Doctrine\DBAL\Schema\Column^ {#9447
    #_name: "action"
    #_namespace: null
    #_quoted: false
    #_type: Base\Enum\EntityAction^ {#476}
    #_length: null
    #_precision: null
    #_scale: 0
    #_unsigned: false
    #_fixed: false
    #_notnull: true
    #_default: null
    #_autoincrement: false
    #_platformOptions: array:1 [
      "version" => false
    ]
    #_columnDefinition: null
    #_comment: "(DC2Type:enum,entity_action)"
  }
}
2^ array:1 [
  0 => "CHANGE action action ENUM('ACTION_DELETE', 'ACTION_INSERT', 'ACTION_UPDATE') NOT NULL COMMENT '(DC2Type:enum,entity_action)'"
]

The ALTER line rendered is the following:
ALTER TABLE extensionAbstract CHANGE action action ENUM('ACTION_DELETE', 'ACTION_INSERT', 'ACTION_UPDATE') NOT NULL COMMENT 'ENUM(ACTION_DELETE, ACTION_INSERT, ACTION_UPDATE)';

I am suspecting the change might be due to some modification in ./vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php; the following line has been modified.

        // In cases where not connected to a database DESCRIBE $table does not return 'Comment'
        if (isset($tableColumn['comment'])) {
            $type                   = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
            $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
        }

How to fix it ?

Expected behavior

Looking at the expected behavior from earlier version, I get should get: #_type: Base\Enum\EntityAction^ {#476} in the db schema, but it returns stringType

Originally created by @meiyasan on GitHub (Jun 17, 2024). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 3.2.0 #### Summary I am investigating an issue with custom EnumType definition in MySQL. I have defined an EnumType following Doctrine predicates quite some time ago; now that I upgraded to the last version of ORM. When I try to upgrade the database, I get a different db schema. #### Current behavior ``` $ php bin/console doctrine:schema:update --dump-sql --force -vvv 1^ Doctrine\DBAL\Schema\ColumnDiff^ {#9492 -oldColumn: Doctrine\DBAL\Schema\Column^ {#9471 #_name: "action" #_namespace: null #_quoted: false #_type: Doctrine\DBAL\Types\StringType^ {#412} #_length: 0 #_precision: null #_scale: 0 #_unsigned: false #_fixed: false #_notnull: true #_default: null #_autoincrement: false #_platformOptions: [] #_columnDefinition: null #_comment: "(DC2Type:enum,entity_action)" } -newColumn: Doctrine\DBAL\Schema\Column^ {#9447 #_name: "action" #_namespace: null #_quoted: false #_type: Base\Enum\EntityAction^ {#476} #_length: null #_precision: null #_scale: 0 #_unsigned: false #_fixed: false #_notnull: true #_default: null #_autoincrement: false #_platformOptions: array:1 [ "version" => false ] #_columnDefinition: null #_comment: "(DC2Type:enum,entity_action)" } } 2^ array:1 [ 0 => "CHANGE action action ENUM('ACTION_DELETE', 'ACTION_INSERT', 'ACTION_UPDATE') NOT NULL COMMENT '(DC2Type:enum,entity_action)'" ] ``` The ALTER line rendered is the following: `ALTER TABLE extensionAbstract CHANGE action action ENUM('ACTION_DELETE', 'ACTION_INSERT', 'ACTION_UPDATE') NOT NULL COMMENT 'ENUM(ACTION_DELETE, ACTION_INSERT, ACTION_UPDATE)';` I am suspecting the change might be due to some modification in `./vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php`; the following line has been modified. ``` // In cases where not connected to a database DESCRIBE $table does not return 'Comment' if (isset($tableColumn['comment'])) { $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); } ``` How to fix it ? #### Expected behavior Looking at the expected behavior from earlier version, I get should get: `#_type: Base\Enum\EntityAction^ {#476}` in the db schema, but it returns stringType
admin closed this issue 2026-01-22 15:51:03 +01:00
Author
Owner

@meiyasan commented on GitHub (Jun 17, 2024):

wrong repo, I just opened a new discussion here: https://github.com/doctrine/dbal/issues/6443

@meiyasan commented on GitHub (Jun 17, 2024): wrong repo, I just opened a new discussion here: https://github.com/doctrine/dbal/issues/6443
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7383