Navigation Menu

Skip to content

Commit

Permalink
Restrict constraint reflection to be on the same schema.
Browse files Browse the repository at this point in the history
Only collect constraint data for matching database names.

Refs #6918
  • Loading branch information
markstory committed Jul 2, 2015
1 parent 29ca3d1 commit c63227e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Database/Schema/MysqlSchema.php
Expand Up @@ -222,8 +222,11 @@ public function describeForeignKeySql($tableName, $config)
{
$sql = 'SELECT * FROM information_schema.key_column_usage AS kcu
INNER JOIN information_schema.referential_constraints AS rc
ON (kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME)
WHERE kcu.TABLE_SCHEMA = ? AND kcu.TABLE_NAME = ? and rc.TABLE_NAME = ?';
ON (
kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
AND kcu.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
)
WHERE kcu.TABLE_SCHEMA = ? AND kcu.TABLE_NAME = ? AND rc.TABLE_NAME = ?';

return [$sql, [$config['database'], $tableName, $tableName]];
}
Expand Down

1 comment on commit c63227e

@GuidoHendriks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the fix. Was about to create a PR for it!

Please sign in to comment.