Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-34: MySql getListTableForeignKeysSQL doesn't work for 5.0.xx #1526

Closed
doctrinebot opened this issue Jul 19, 2010 · 5 comments
Closed

DBAL-34: MySql getListTableForeignKeysSQL doesn't work for 5.0.xx #1526

doctrinebot opened this issue Jul 19, 2010 · 5 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user tiw:

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

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Comment created by gedrox:

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.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants