1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-11 17:14:07 +02:00

MS SQL: Display foreign keys ON UPDATE and ON DELETE

This commit is contained in:
Jakub Vrana
2025-02-26 14:23:38 +01:00
parent 76cc7c6614
commit d54be5ac2e
3 changed files with 7 additions and 2 deletions

View File

@@ -571,10 +571,13 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
function foreign_keys($table) {
$return = array();
$on_actions = array("CASCADE", "NO ACTION", "SET NULL", "SET DEFAULT");
foreach (get_rows("EXEC sp_fkeys @fktable_name = " . q($table) . ", @fktable_owner = " . q(get_schema())) as $row) {
$foreign_key = &$return[$row["FK_NAME"]];
$foreign_key["db"] = $row["PKTABLE_QUALIFIER"];
$foreign_key["table"] = $row["PKTABLE_NAME"];
$foreign_key["on_update"] = $on_actions[$row["UPDATE_RULE"]];
$foreign_key["on_delete"] = $on_actions[$row["DELETE_RULE"]];
$foreign_key["source"][] = $row["FKCOLUMN_NAME"];
$foreign_key["target"][] = $row["PKCOLUMN_NAME"];
}
@@ -724,6 +727,8 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
}
function driver_config() {
global $on_actions;
$on_actions = str_replace('RESTRICT|', '', $on_actions);
$types = array();
$structured_types = array();
foreach (array( //! use sys.types