You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever a Doctrine migration is created with --formatted option, i.e., SQLFormatter is used under the hood, the DEFAULT CHARACTER SET statement is formatted in quite a bizarre way, see steps to reproduce.
I'm using MariaDB 11.2.2 on this machine.
Current behavior
Now it's like this for some reason:
[...]
PRIMARY KEY(id)
) DEFAULT CHARACTER
SET
utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
Expected behavior
I would expect rather:
[...]
PRIMARY KEY(id)
)
DEFAULT CHARACTER SET utf8mb4
COLLATE `utf8mb4_unicode_ci`
ENGINE = InnoDB'
How to reproduce
Basically, make a migration with doctrine:migrations:diff --formatted or, if you are like me into Symfony, with make:migration --formatted. Here's one full migration for reference:
<?phpdeclare(strict_types=1);
namespaceDoctrineMigrations;
useDoctrine\DBAL\Schema\Schema;
useDoctrine\Migrations\AbstractMigration;
finalclass Version20250109223941 extends AbstractMigration
{
publicfunctiongetDescription(): string
{
return'Created languages table';
}
publicfunctionup(Schema$schema): void
{
$this->addSql('CREATE TABLE languages ( id INT AUTO_INCREMENT NOT NULL, position SMALLINT UNSIGNED NOT NULL, code VARCHAR(20) NOT NULL, english_name VARCHAR(100) NOT NULL, native_name VARCHAR(100) NOT NULL, PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
publicfunctiondown(Schema$schema): void
{
$this->addSql('DROP TABLE languages');
}
}
I tried to dig in deeper to understand how to fix that, but so far I probably spent too little time on it, have no idea how it can be fixed appropriately.
The text was updated successfully, but these errors were encountered:
This library does not intend to parse full SQL grammar.
Both CHARACTER, SET are reserved keywords and per MySQL https://dev.mysql.com/doc/refman/8.4/en/create-table.html grammar there cannot be anything in between, the SET can be "weakened", ie. not assumed to be an isolated SET keyword used frequently in UPDATE ... SET ..., when CHARACTER is before the SET keyword.
Bug Report
Summary
Whenever a Doctrine migration is created with
--formatted
option, i.e., SQLFormatter is used under the hood, theDEFAULT CHARACTER SET
statement is formatted in quite a bizarre way, see steps to reproduce.I'm using MariaDB 11.2.2 on this machine.
Current behavior
Now it's like this for some reason:
Expected behavior
I would expect rather:
How to reproduce
Basically, make a migration with
doctrine:migrations:diff --formatted
or, if you are like me into Symfony, withmake:migration --formatted
. Here's one full migration for reference:I tried to dig in deeper to understand how to fix that, but so far I probably spent too little time on it, have no idea how it can be fixed appropriately.
The text was updated successfully, but these errors were encountered: