Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3007

ManyToMany does not respect all column attributes for the jointable

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None

      Description

      Given following 2 entities:

      <?php
      class Role {
          /**
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="UUID")
           * @ORM\Column(name="id", type="guid", nullable=false, unique=true, length=36, options={"fixed"=true})
           */
          protected $id;
      
          /**
           * @ORM\ManyToMany(targetEntity="User", mappedBy="roleList")
           */
          private $userList;
      }
      
      <?php
      class User {
          /**
           * @ORM\Column(name="id", type="guid", nullable=false, unique=true, length=36, options={"fixed"=true})
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="UUID")
           */
          protected $id;
      
          /**     *
           * @ORM\ManyToMany(targetEntity="Role", inversedBy="userList")
           * @ORM\JoinTable(name="user_role")
          protected $roleList;
      }
      

      It should create a table "user_role" with 2 columns which are CHAR(36).

      But it ignores the Column-Attributes and creates a table "user_role" with 2 CHAR(255) columns.

      This has various downsides:

      • It's unusable when using MyISAM, because of limited index size. (CREATE TABLE fails, see DBAL-423)
      • If using GUID-Type (see DBAL-423 with the changes from the linked ull request) and specify "length=36" and "fixed=true" on the Column-Annotation, no changes for the entity-tables itself are generated when running orm:schema-tool:update. However, there are still changes for the many-to-many-table generated (because internal "fixed" is false and length is unset) which represent the current state of the columns. These changes are always generated.

        Activity

        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-465] was assigned:
        https://github.com/doctrine/dbal/pull/465

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-465] was assigned: https://github.com/doctrine/dbal/pull/465

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Michael Kühn
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: