Uploaded image for project: '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


    • Type: Bug
    • Status: Awaiting Feedback
    • Priority: 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:
    • Environment:
      Symfony 2.2.0, MySQL 5.1


      (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`)

      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.



          • Assignee:
            beberlei Benjamin Eberlei
            succinct Nicholas Van Dusen
          • Votes:
            5 Vote for this issue
            10 Start watching this issue


            • Created: