DDC-3880: Attribute overrides for FOSUserBundle #4750

Open
opened 2026-01-22 14:48:43 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 26, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user Poule_R:

Hi,

We're using the FOSUserBundle with Doctrine and we're using utf8mb4 for our database and tables. Therefore we need to change the length of the following fields:

  • usernameCanonical
  • username
  • emailCanonical
  • email

So I've created these attribute overrides in our XML file:

        <?xml version="1.0" encoding="utf-8"?>
    <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"     xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
      <entity repository-class="Pler\UserBundle\Entity\UserRepository" name="Pler\UserBundle\Entity\User" table="fos_user">
        <attribute-overrides>
            <attribute-override name="usernameCanonical">
                <field column="username_canonical" length="191" unique="true" name="usernameCanonical" type="string" />
            </attribute-override>
            <attribute-override name="username">
                <field column="username" length="191" />
            </attribute-override>
            <attribute-override name="emailCanonical">
                <field column="email_canonical" length="191" />
            </attribute-override>
            <attribute-override name="email">
                <field column="email" length="191" />
            </attribute-override>
        </attribute-overrides>
        <options>
          <option name="charset">utf8mb4</option>
          <option name="collate">utf8mb4*general*ci</option>
        </options>

But when I try to generate the entities (for other bundles for e.g.) I get this error:

[Doctrine\ORM\Mapping\MappingException]                                              
Invalid field override named 'username' for class 'Pler\UserBundle\Entity\User'.

My current work-around is to remove the attribute-overrides from the XML file and generate the entities, however I'm searching for a real solution. How can I fix this error?

Originally created by @doctrinebot on GitHub (Aug 26, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user Poule_R: Hi, We're using the FOSUserBundle with Doctrine and we're using utf8mb4 for our database and tables. Therefore we need to change the length of the following fields: - usernameCanonical - username - emailCanonical - email So I've created these attribute overrides in our XML file: ``` <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"> <entity repository-class="Pler\UserBundle\Entity\UserRepository" name="Pler\UserBundle\Entity\User" table="fos_user"> <attribute-overrides> <attribute-override name="usernameCanonical"> <field column="username_canonical" length="191" unique="true" name="usernameCanonical" type="string" /> </attribute-override> <attribute-override name="username"> <field column="username" length="191" /> </attribute-override> <attribute-override name="emailCanonical"> <field column="email_canonical" length="191" /> </attribute-override> <attribute-override name="email"> <field column="email" length="191" /> </attribute-override> </attribute-overrides> <options> <option name="charset">utf8mb4</option> <option name="collate">utf8mb4*general*ci</option> </options> ``` But when I try to generate the entities (for other bundles for e.g.) I get this error: ``` [Doctrine\ORM\Mapping\MappingException] Invalid field override named 'username' for class 'Pler\UserBundle\Entity\User'. ``` My current work-around is to remove the attribute-overrides from the XML file and generate the entities, however I'm searching for a real solution. How can I fix this error?
admin added the Bug label 2026-01-22 14:48:43 +01:00
Author
Owner

@violuke commented on GitHub (May 27, 2016):

I'm also having the same problem (using annotations). Any chance this could be fixed?

@violuke commented on GitHub (May 27, 2016): I'm also having the same problem (using annotations). Any chance this could be fixed?
Author
Owner

@CountZero1981 commented on GitHub (Jul 20, 2016):

the same here

@CountZero1981 commented on GitHub (Jul 20, 2016): the same here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4750