dbal
dbal copied to clipboard
Doctrine DBAL not picking up Table Comment updates
Bug Report
Q | A |
---|---|
DBAL Version | 3.7.1 |
Migrations version | 3.2.4 |
Summary
I am working on an anonymizer-tool, that works with table- and column based comments. That way the anonymizer can run plainly with DBAL, without the tool needing access to project-specific files. Therefore, I need to be able to update a table comment.
Current behaviour
DBAL is detecting a comment that is being set on a new table, and also notices the changes on a column correctly. But updating the comment on an existing table is not being detected, and leads to a "No changes detected in your mapping information." when running (symfony) bin/console doctrine:migrations:diff
, even when there are changes to the table comment.
How to reproduce
- Generate an Entity, with relevant Table annotations, without comment
<?
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TestEntityRepository::class)
* @ORM\Table()
*/
class TestEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
}
- Generate and execute the migration, storing the table in the Database
(symfony) bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate
- Update the Entity to have a comment:
...
/**
* @ORM\Entity(repositoryClass=TestEntityRepository::class)
* @ORM\Table(options={"comment": "Testcomment"})
*/
class TestEntity
{
...
- Generate the migration
(symfony) bin/console doctrine:migrations:diff
- Be presented with a faillure that there are no changes...
Expected behaviour
At least, I expect DBAL to detect the comment being updated. Preferably, I even would like Migrations to actually write the migration query necessary
When dumping both schemas in Doctrine\Migrations\Generator\DiffGenerator::generate()
, @ line 91 just after both schemas have been generated, I am presented with the following _options
arrays on the TestEntity table
From schema:
Schema > _tables > anonymize.test_entity (instanceof DBAL\Schema\Table)
#_options: array:6 [
"create_options" => []
"engine" => "InnoDB"
"collation" => "utf8mb4_unicode_ci"
"charset" => "utf8mb4"
"autoincrement" => null
"comment" => ""
]
To schema:
Schema > _tables > anonymize.test_entity (instanceof DBAL\Schema\Table)
#_options: array:3 [
"create_options" => []
"charset" => "utf8mb4"
"comment" => "Testcomment"
]
So, the DBAL Schema gets updated. But, Doctrine\DBAL\Schema\TableDiff
seems to be unable to detect changes on tables other than renames, columns, indexes and foreign keys...
Are you able to reproduce this issue by using DBAL APIs only?
Yes. DBAL is not producing the diff for an updated table comment, and it seems TableDiff has no ability to handle them.
I am currently away from my PC and thus unable to generate a DBAL Only example.
Same issue here