1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-09 08:06:59 +02:00

MS SQL: Split altering foreign key to two commands

This commit is contained in:
Jakub Vrana
2025-02-26 14:25:57 +01:00
parent d54be5ac2e
commit ce1031e017
2 changed files with 10 additions and 10 deletions

View File

@@ -4,9 +4,6 @@ $name = $_GET["name"];
$row = $_POST; $row = $_POST;
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) { if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
$message = ($_POST["drop"] ? lang('Foreign key has been dropped.') : ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
$location = ME . "table=" . urlencode($TABLE);
if (!$_POST["drop"]) { if (!$_POST["drop"]) {
$row["source"] = array_filter($row["source"], 'strlen'); $row["source"] = array_filter($row["source"], 'strlen');
ksort($row["source"]); // enforce input order ksort($row["source"]); // enforce input order
@@ -18,17 +15,19 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
} }
if ($jush == "sqlite") { if ($jush == "sqlite") {
queries_redirect($location, $message, recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($_POST["drop"] ? "" : " " . format_foreign_key($row))))); $result = recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($row["drop"] ? "" : " " . format_foreign_key($row))));
} else { } else {
$alter = "ALTER TABLE " . table($TABLE); $alter = "ALTER TABLE " . table($TABLE);
$drop = "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name); $result = ($name == "" || queries("$alter DROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name)));
if ($_POST["drop"]) { if (!$row["drop"]) {
query_redirect($alter . $drop, $location, $message); $result = queries("$alter ADD" . format_foreign_key($row));
} else {
query_redirect($alter . ($name != "" ? "$drop," : "") . "\nADD" . format_foreign_key($row), $location, $message);
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
} }
} }
queries_redirect(
ME . "table=" . urlencode($TABLE),
($row["drop"] ? lang('Foreign key has been dropped.') : ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))),
$result
);
} }
page_header(lang('Foreign key'), $error, array("table" => $TABLE), h($TABLE)); page_header(lang('Foreign key'), $error, array("table" => $TABLE), h($TABLE));

View File

@@ -5,6 +5,7 @@ SQLite: Display all rows of variable values
SQLite: Remove support for SQLite version 2 SQLite: Remove support for SQLite version 2
MS SQL: Support export (bug #480) MS SQL: Support export (bug #480)
MS SQL: Display foreign keys ON UPDATE and ON DELETE MS SQL: Display foreign keys ON UPDATE and ON DELETE
MS SQL: Fix altering foreign key
MongoDB: Remove support for deprecated extension mongo MongoDB: Remove support for deprecated extension mongo
Adminer-4.17.1 (released 2025-02-25): Adminer-4.17.1 (released 2025-02-25):