doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.86k stars 2.5k forks source link

Missing default length on ID field type string #11382

Open bigfoot90 opened 3 months ago

bigfoot90 commented 3 months ago

BC Break Report

Q A
BC Break yes
Version 3.1.0

Summary

Migrating from 2.19.2 to 3.1.0 I'm getting an error running schema:diff Error:

In InvalidColumnDeclaration.php line 17:
  Column "site_name" has invalid type  

In ColumnLengthRequired.php line 26:
  Doctrine\DBAL\Platforms\MariaDB1060Platform requires the length of a VARCHAR column to be specified  

Previous behavior

Mapping before migration:

    <entity name="Domain\Model\Entity\Site">
        <id name="name" type="string"/>
        <field name="token" unique="true"/>
    </entity>

Current behavior

Actual mapping:

    <entity name="Domain\Model\Entity\Site">
        <id name="name" type="string" length="255"/>
        <field name="token" unique="true"/>
    </entity>

Expected behavior

Be able to migrate schema without errors and don't see changes on column name length.

How to reproduce

Create an entity with Id type string. Value 255 was the default length for type string in ORM 2.19

herndlm commented 1 month ago

I'm not sure if you're saying that the issue is that you need to add length now, which is expected I guess. But I had a similar problem and it turned out that an outdated cache was the reason. We have an app with a custom bootstrapped EntityManager which uses an instance of ORMSetup where we pass a Symfony FilesystemAdapter. Long story short, I had to just clear that directory and it started working.