Skip to content
Browse files

SQLite: Display auto-created unique indexes

  • Loading branch information...
1 parent f4592e3 commit 3e2288eee55a4483fed1df0c5afb1059288fda3d @vrana committed Feb 4, 2014
Showing with 16 additions and 11 deletions.
  1. +15 −11 adminer/drivers/sqlite.inc.php
  2. +1 −0 changes.txt
View
26 adminer/drivers/sqlite.inc.php
@@ -352,20 +352,24 @@ function indexes($table, $connection2 = null) {
$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;
}
View
1 changes.txt
@@ -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

0 comments on commit 3e2288e

Please sign in to comment.
Something went wrong with that request. Please try again.