Details
Description
Encoutered this error while attempting to reverse engineer a database. Was previously working with 2.0-ALPHA4 so this is the result of some change between ALPHA4 and BETA1.
The reverse engineering process fails with a Doctrine\ORM\Mapping\MappingException with message "No identifier/primary key specified for Entity `mytable`. Every entity must have an identifier/primary key."
This exception is thrown because the "identifier" property of the ClassMetadataInfo object passed to loadMetadataForClass is not populated with the expected value (which in this case should be array('a_id', 'b_id')
It appears that this is caused by the following code in \Doctrine\ORM\Mapping\DatabaseDriver::loadMetadataForClass():
// Skip columns that are foreign keys
foreach ($foreignKeys as $foreignKey) {
if (in_array(strtolower($column->getName()), array_map('strtolower', $foreignKey->getColumns()))) {
continue(2);
}
}
The table definition is something like:
CREATE TABLE a ( a_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (a_id) ) ENGINE=InnoDB; CREATE TABLE b ( b_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (b_id) ) ENGINE=InnoDB; /* this is the table that fails to be reverse engineered */ CREATE TABLE mytable ( a_id BIGINT UNSIGNED NOT NULL, b_id BIGINT UNSIGNED NOT NULL, PRIMARY KEY (a_id, b_id), CONSTRAINT `a_id_ibfk` FOREIGN KEY (`a_id`) REFERENCES `a` (`a_id`), CONSTRAINT `b_id_ibfk` FOREIGN KEY (`b_id`) REFERENCES `b` (`b_id`), ) ENGINE=InnoDB;
Activity
Roman S. Borschel
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Roman S. Borschel [ romanb ] | Jonathan H. Wage [ jwage ] |
Roman S. Borschel
made changes -
| Fix Version/s | 2.0-BETA2 [ 10050 ] |
Jonathan H. Wage
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 11281 ] | jira-feedback [ 14405 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 14405 ] | jira-feedback2 [ 16269 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 16269 ] | jira-feedback3 [ 18522 ] |