Skip to content

Loading…

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 · 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
@doctrinebot doctrinebot added this to the 2.0.1 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.