Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-34

MySql getListTableForeignKeysSQL doesn't work for 5.0.xx

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-BETA2
    • Fix Version/s: 2.0.0-BETA3
    • Component/s: Schema Managers
    • Labels:
      None
    • Environment:
      MySQL Server version: 5.0.51a-24+lenny4 (Debian)

      Description

      The sql contains mysql specific code. And for the mysql 5.0.xxx the sql statement has syntax error.

      in /Doctrine/DBAL/Platforms/MySqlPlatform.php:
      public function getListTableForeignKeysSQL($table, $database = null)
      {
      $sql = "SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, ".
      "k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ ".
      "FROM information_schema.key_column_usage k /*!50116 ".
      "INNER JOIN information_schema.referential_constraints c ON ".
      " c.constraint_name = k.constraint_name AND ".
      " c.table_name = '$table' */ WHERE k.table_name = '$table'";

      if ($database)

      { $sql .= " AND k.table_schema = '$database' AND c.constraint_schema = '$database'"; }

      $sql .= " AND `REFERENCED_COLUMN_NAME` is not NULL";

      return $sql;
      }

      For the mysql lower as 5.1.16 the SQL could be as the following:

      SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` FROM information_schema.key_column_usage k WHERE k.table_name = 'some_table' AND k.table_schema = 'some database' AND c.constraint_schema = 'some database' AND `REFERENCED_COLUMN_NAME` is not NULL

      In this statement there is no reference of c

        Activity

        Ting Wang created issue -
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0-BETA3 [ 10066 ]
        Resolution Fixed [ 1 ]
        Hide
        Aigars Gedroics added a comment -

        Pity that because of this the Doctrine schema-tool update action reports incorrect change list.
        It tries to drop/add foreign keys because "ON DELETE CASCADE" option isn't read from the database at all.

        Show
        Aigars Gedroics added a comment - Pity that because of this the Doctrine schema-tool update action reports incorrect change list. It tries to drop/add foreign keys because "ON DELETE CASCADE" option isn't read from the database at all.
        Hide
        Benjamin Eberlei added a comment -

        5.0.x has no way to export the CASCADE details. Its just not possible to get this data in 5.0

        Show
        Benjamin Eberlei added a comment - 5.0.x has no way to export the CASCADE details. Its just not possible to get this data in 5.0
        Benjamin Eberlei made changes -
        Workflow jira [ 11639 ] jira-feedback2 [ 17651 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17651 ] jira-feedback3 [ 20006 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-34, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Ting Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: