mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Fix foreign key schema
This commit is contained in:
@@ -271,7 +271,7 @@ ORDER BY a.attnum"
|
||||
function foreign_keys($table) {
|
||||
global $on_actions;
|
||||
$return = array();
|
||||
foreach (get_rows("SELECT conname, (SELECT nspname FROM pg_namespace WHERE oid = connamespace) AS ns, pg_get_constraintdef(oid) AS definition
|
||||
foreach (get_rows("SELECT conname, pg_get_constraintdef(oid) AS definition
|
||||
FROM pg_constraint
|
||||
WHERE conrelid = (SELECT oid FROM pg_class WHERE relname = " . q($table) . ")
|
||||
AND contype = 'f'::char
|
||||
@@ -279,6 +279,10 @@ ORDER BY conkey, conname") as $row) {
|
||||
if (preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA', $row['definition'], $match)) {
|
||||
$row['source'] = array_map('trim', explode(',', $match[1]));
|
||||
$row['table'] = $match[2];
|
||||
if (preg_match('~(.+)\.(.+)~', $match[2], $match2)) {
|
||||
$row['ns'] = $match2[1];
|
||||
$row['table'] = $match2[2];
|
||||
}
|
||||
$row['target'] = array_map('trim', explode(',', $match[3]));
|
||||
$row['on_delete'] = (preg_match('~ON DELETE (' . implode('|', $on_actions) . ')~', $match[4], $match2) ? $match2[1] : '');
|
||||
$row['on_update'] = (preg_match('~ON UPDATE (' . implode('|', $on_actions) . ')~', $match[4], $match2) ? $match2[1] : '');
|
||||
|
Reference in New Issue
Block a user