]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Display auto-created unique indexes
authorJakub Vrana <jakub@vrana.cz>
Tue, 4 Feb 2014 17:50:31 +0000 (09:50 -0800)
committerJakub Vrana <jakub@vrana.cz>
Tue, 4 Feb 2014 17:50:31 +0000 (09:50 -0800)
adminer/drivers/sqlite.inc.php
changes.txt

index 9cf221ccc6d7cb42dfe37aa70cd7d42a1ef6c344..6f63d4ccf21cee2f69da9fe0341fa31b84b41d03 100644 (file)
@@ -352,20 +352,24 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                $sqls = get_key_vals("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = " . q($table), $connection2);
                foreach (get_rows("PRAGMA index_list(" . table($table) . ")", $connection2) as $row) {
                        $name = $row["name"];
-                       if (!preg_match("~^sqlite_~", $name)) {
-                               $return[$name]["type"] = ($row["unique"] ? "UNIQUE" : "INDEX");
-                               $return[$name]["lengths"] = array();
-                               foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")", $connection2) as $row1) {
-                                       $return[$name]["columns"][] = $row1["name"];
-                               }
-                               $return[$name]["descs"] = array();
-                               if (preg_match('~^CREATE( UNIQUE)? INDEX ' . preg_quote(idf_escape($name) . ' ON ' . idf_escape($table), '~') . ' \((.*)\)$~i', $sqls[$name], $regs)) {
-                                       preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
-                                       foreach ($matches[2] as $val) {
-                                               $return[$name]["descs"][] = ($val ? '1' : null);
+                       $index = array("type" => ($row["unique"] ? "UNIQUE" : "INDEX"));
+                       $index["lengths"] = array();
+                       $index["descs"] = array();
+                       foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")", $connection2) as $row1) {
+                               $index["columns"][] = $row1["name"];
+                               $index["descs"][] = null;
+                       }
+                       if (preg_match('~^CREATE( UNIQUE)? INDEX ' . preg_quote(idf_escape($name) . ' ON ' . idf_escape($table), '~') . ' \((.*)\)$~i', $sqls[$name], $regs)) {
+                               preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
+                               foreach ($matches[2] as $key => $val) {
+                                       if ($val) {
+                                               $index["descs"][$key] = '1';
                                        }
                                }
                        }
+                       if (!$return[""] || $index["type"] != "UNIQUE" || $index["columns"] != $return[""]["columns"] || $index["descs"] != $return[""]["descs"] || !preg_match("~^sqlite_~", $name)) {
+                               $return[$name] = $index;
+                       }
                }
                return $return;
        }
index efa698cccaf91b37ec94ac67facda852ed870751..7ef8c7e38cea4c1a80079497c6ece08adf2dc6da 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.0.4-dev:
+SQLite: Display auto-created unique indexes, bug since Adminer 3.5.0
 
 Adminer 4.0.3 (released 2014-02-01)
 MongoDB: insert, truncate, indexes