DDC-929: A index has to be named as "primary" to be detected Doctrine\ORM\Mapping\Driver\DatabaseDriver::loadMetadataForClass() #5458

Closed
doctrinebot opened this Issue Dec 13, 2010 · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user teuzz:

Condition

if (isset($indexes['primary']) && in_array($column->getName(), $indexes['primary']->getColumns())) {

needs the primary key to be named as primary. Discovered this when reverse engineering an existing database.

Fix, that worked for me:

Replace:

if (isset($indexes['primary']) && in_array($column->getName(), $indexes['primary']->getColumns())) {
$fieldMapping['id'] = true;

With:

$primary = false;

foreach ($indexes as $index)
{
    if ($index->isPrimary())
    {
        if (in_array($column->getName(), $index->getColumns()))
        {
            $primary = true;
            break;
        }
    }
}

        if ($primary){    
    $fieldMapping['id'] = true;
@doctrinebot

Comment created by @beberlei:

Fixed.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0.1 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment