Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2387

convert-mapping not working correctly with composite primary keys/foreign keys in 2.4.0-RC1

    Details

    • Type: Bug Bug
    • Status: Awaiting Feedback
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4
    • Fix Version/s: 2.3.4
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony 2.2.0, MySQL 5.1

      Description

      (Apologies if this is somehow a Symfony-specific issue)

      I updated my application via Composer yesterday, and received Doctrine 2.4.0-RC1. After this update, generating entities has been problematic under certain circumstances.

      Here is an example table in MySQL:

      CREATE TABLE `user_email` (
        `user_id` int(10) unsigned NOT NULL COMMENT 'FK to user',
        `email` varchar(254) NOT NULL,
        `email_datasource` smallint(1) unsigned NOT NULL COMMENT 'FK to datasource_code',
        `insert_date` datetime NOT NULL,
        PRIMARY KEY (`user_id`,`email`,`email_datasource`),
        KEY `FK_UserEmail_DataSourceCode` (`email_datasource`),
        CONSTRAINT `FK_UserEmail_User` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8
      

      In Doctrine 2.3, the mapping works correctly, and you end up with a 3-part primary key, with a user property mapped to the User entity, and a datasourceCode property mapped to the DatasourceCode entity. All good.

      In 2.4, the following error is given: Single id is not allowed on composite primary key in entity UserEmail.

      Removing one of the foreign keys in the table (either to User or DatasourceCode) but keeping the primary key set to all 3 columns allows the mapping to work. But, if you then remove one of the columns from the primary key (say, email_datasource) it fails again.

        Activity

        Nicholas Van Dusen created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.3.4 [ 10420 ]
        Fix Version/s 2.4 [ 10321 ]
        Resolution Fixed [ 1 ]
        Nicholas Van Dusen made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Sam Van der Borght made changes -
        Status Reopened [ 4 ] Awaiting Feedback [ 10000 ]
        Diego Antunes made changes -
        Affects Version/s 2.3.4 [ 10420 ]
        Affects Version/s 2.3.3 [ 10329 ]
        Affects Version/s 2.3.2 [ 10324 ]
        Affects Version/s 2.3.1 [ 10323 ]
        Affects Version/s 2.3 [ 10185 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Nicholas Van Dusen
          • Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated: