Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-874 orm:convert-mapping
  3. DDC-929

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

    Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC2
    • Fix Version/s: 2.0.1, 2.1
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None
    • Environment:
      FreeBSD, PostgreSQL 8.4

      Description

      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;

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jiri Helmich
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: