Doctrine 1
  1. Doctrine 1
  2. DC-678

Need case-insensitive checks for dupes in the $options['indexes'] array

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.2.3
    • Component/s: Import/Export
    • Labels:
      None
    • Environment:
      PHP 5.3, OSX, APC

      Description

      I ran into a bug where there were two duplicate indexes that Doctrine was trying to create.

      Not too sure what the cause is yet but this fix took care of the problem for me.

      Line 161 of Doctrine/Export/MySQL.php

      // Case Insensitive checking for duplicate indexes...
      $dupes = array();
      foreach ($options['indexes'] as $key => $index) {
      if (in_array(strtolower($key), $dupes))

      { unset($options['indexes'][$key]); }

      else

      { $dupes[] = strtolower($key); }

      }
      unset($dupes);

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I don't think this is a good change. You should instead fix it by identifying why you have 2 indexes with the same name, instead of this hack.

        Show
        Jonathan H. Wage added a comment - I don't think this is a good change. You should instead fix it by identifying why you have 2 indexes with the same name, instead of this hack.
        Hide
        Bryan Zarzuela added a comment -

        I'll try to debug why there were two indexes named employeecode and employeeCode. I think there's a bug somewhere in the MySQL drivers where the case-conversions failed.

        Had no time yesterday as I was focused more on getting my work done than actually fixing the problem

        Show
        Bryan Zarzuela added a comment - I'll try to debug why there were two indexes named employeecode and employeeCode. I think there's a bug somewhere in the MySQL drivers where the case-conversions failed. Had no time yesterday as I was focused more on getting my work done than actually fixing the problem
        Hide
        Bryan Zarzuela added a comment -

        If you do this in the base model, note the capital C in the employeeCode index:

        $this->hasColumn('employeeCode', 'string', 11);
        $this->index('employeeCode', array('fields' => array('employeeCode')));

        It will result in this SQL statement for the table creation:

        CREATE TABLE employees (id BIGINT AUTO_INCREMENT, employeecode VARCHAR(11), first VARCHAR(50), last VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX employeeCode_idx (employeecode), INDEX employeecode_idx (employeecode), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB

        Note that it tries to create 2 indexes named employeeCode_idx and employeecode_idx.

        If I change the declaration to $this->index('employeecode', array('fields' => array('employeeCode')));, then it works:

        CREATE TABLE employees (id BIGINT AUTO_INCREMENT, first VARCHAR(50), last VARCHAR(50), employeecode VARCHAR(11), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX employeecode_idx (employeecode), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB

        Still not sure what the cause is. I'm not too familiar with the flow of the Export Drivers yet.

        Show
        Bryan Zarzuela added a comment - If you do this in the base model, note the capital C in the employeeCode index: $this->hasColumn('employeeCode', 'string', 11); $this->index('employeeCode', array('fields' => array('employeeCode'))); It will result in this SQL statement for the table creation: CREATE TABLE employees (id BIGINT AUTO_INCREMENT, employeecode VARCHAR(11), first VARCHAR(50), last VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX employeeCode_idx (employeecode), INDEX employeecode_idx (employeecode), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB Note that it tries to create 2 indexes named employeeCode_idx and employeecode_idx. If I change the declaration to $this->index('employeecode', array('fields' => array('employeeCode')));, then it works: CREATE TABLE employees (id BIGINT AUTO_INCREMENT, first VARCHAR(50), last VARCHAR(50), employeecode VARCHAR(11), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX employeecode_idx (employeecode), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB Still not sure what the cause is. I'm not too familiar with the flow of the Export Drivers yet.
        Hide
        Jonathan H. Wage added a comment -

        I see, I think we have some problems when you have columns which are camel case. I would recommend using underscores to avoid any issues until this can be resolved.

        Show
        Jonathan H. Wage added a comment - I see, I think we have some problems when you have columns which are camel case. I would recommend using underscores to avoid any issues until this can be resolved.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Bryan Zarzuela
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: