]> git.joonet.de Git - adminer.git/commitdiff
MS SQL: Fix length of nvarchar columns
authorJakub Vrana <jakub@vrana.cz>
Sat, 22 Feb 2025 09:39:14 +0000 (10:39 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sat, 22 Feb 2025 09:39:14 +0000 (10:39 +0100)
adminer/drivers/mssql.inc.php
changes.txt

index 6f8d8ef3be9990cf7288bce4a8bb69ba54eceaa4..a597d9cc00aa7d56b9a750bf72d9eb01feaac2a1 100644 (file)
@@ -393,7 +393,10 @@ LEFT JOIN sys.default_constraints d ON c.default_object_id = d.object_id
 WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U', 'V') AND o.name = " . q($table)
                ) as $row) {
                        $type = $row["type"];
-                       $length = (preg_match("~char|binary~", $type) ? $row["max_length"] : ($type == "decimal" ? "$row[precision],$row[scale]" : ""));
+                       $length = (preg_match("~char|binary~", $type)
+                               ? $row["max_length"] / ($type[0] == 'n' ? 2 : 1)
+                               : ($type == "decimal" ? "$row[precision],$row[scale]" : "")
+                       );
                        $return[$row["name"]] = array(
                                "field" => $row["name"],
                                "full_type" => $type . ($length ? "($length)" : ""),
index 0f1be4a7bc2695106832f34bd796f3cc9ef1152c..3df7fd20f4f7410630624ba13c62e8f991da6d4e 100644 (file)
@@ -3,6 +3,7 @@ Hide index column options by default
 SQLite: Show all supported pragmas in Variables
 MS SQL: Allow altering table in non-default schema (bug #405)
 MS SQL: Display default values (bug #732)
+MS SQL: Fix length of nvarchar columns
 Editor: PDO: Select value of foreign key in edit (bug #847)
 
 Adminer 4.16.0 (released 2025-02-20):