PostgreSQL: Export schema in REFERENCES

This commit is contained in:
Jakub Vrana
2026-03-01 17:57:27 +01:00
parent e5e9b3a04d
commit 11234ef939
2 changed files with 3 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
- PostgreSQL: Order NULL last
- PostgreSQL: Display all SQL command warnings and only once
- PostgreSQL: Export schema in nextval()
- PostgreSQL: Export schema in REFERENCES
- Editor: Display tinyint(1) as checkbox (bug #1246, regression from 5.4.2)
- Croatian translation

View File

@@ -915,11 +915,12 @@ AND typelem = 0"
$return = "";
$status = table_status1($table);
$ns = idf_escape($status['nspname']);
$fkeys = foreign_keys($table);
ksort($fkeys);
foreach ($fkeys as $fkey_name => $fkey) {
$return .= "ALTER TABLE ONLY " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . " ADD CONSTRAINT " . idf_escape($fkey_name) . " $fkey[definition];\n";
$return .= "ALTER TABLE ONLY $ns." . idf_escape($status['Name']) . " ADD CONSTRAINT " . idf_escape($fkey_name) . " " . preg_replace('~( REFERENCES )([^(.]+\()~', "\\1$ns.\\2", $fkey["definition"]) . ";\n";
}
return ($return ? "$return\n" : $return);