Skip to content
Permalink
Browse files

Restrict constraint reflection to be on the same schema.

Only collect constraint data for matching database names.

Refs #6918
  • Loading branch information...
markstory committed Jul 2, 2015
1 parent 29ca3d1 commit c63227e2b6142f4364b25192b38872fc91399360
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/Database/Schema/MysqlSchema.php
@@ -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]];
}

1 comment on commit c63227e

@GuidoHendriks

This comment has been minimized.

Copy link

GuidoHendriks commented on c63227e Jul 6, 2015

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

Please sign in to comment.
You can’t perform that action at this time.