]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Fix creating table and altering primary key (bug #373)
authorJakub Vrana <jakub@vrana.cz>
Thu, 30 Jan 2014 17:35:17 +0000 (09:35 -0800)
committerJakub Vrana <jakub@vrana.cz>
Thu, 30 Jan 2014 17:39:15 +0000 (09:39 -0800)
adminer/drivers/sqlite.inc.php
changes.txt

index a10cd1919d3918bd06213348f29af2119d27eab0..9cf221ccc6d7cb42dfe37aa70cd7d42a1ef6c344 100644 (file)
@@ -497,7 +497,6 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        }
 
        function recreate_table($table, $name, $fields, $originals, $foreign, $indexes = array()) {
-               queries("BEGIN");
                if ($table != "") {
                        if (!$fields) {
                                foreach (fields($table) as $key => $field) {
@@ -506,11 +505,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                                }
                        }
                        $primary_key = false;
-                       foreach ($fields as $key => $field) {
+                       foreach ($fields as $field) {
                                if ($field[6]) {
                                        $primary_key = true;
                                }
-                               $fields[$key] = "  " . implode($field);
                        }
                        $drop_indexes = array();
                        foreach ($indexes as $key => $val) {
@@ -527,7 +525,6 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                                        }
                                        $columns[] = $originals[$column] . ($index["descs"][$key] ? " DESC" : "");
                                }
-                               $columns = "(" . implode(", ", $columns) . ")";
                                if (!$drop_indexes[$key_name]) {
                                        if ($index["type"] != "PRIMARY" || !$primary_key) {
                                                $indexes[] = array($index["type"], $key_name, $columns);
@@ -537,7 +534,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                        foreach ($indexes as $key => $val) {
                                if ($val[0] == "PRIMARY") {
                                        unset($indexes[$key]);
-                                       $foreign[] = "  PRIMARY KEY $val[2]";
+                                       $foreign[] = "  PRIMARY KEY (" . implode(", ", $val[2]) . ")";
                                }
                        }
                        foreach (foreign_keys($table) as $key_name => $foreign_key) {
@@ -551,6 +548,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                                        $foreign[] = " " . format_foreign_key($foreign_key);
                                }
                        }
+                       queries("BEGIN");
+               }
+               foreach ($fields as $key => $field) {
+                       $fields[$key] = "  " . implode($field);
                }
                $fields = array_merge($fields, array_filter($foreign));
                if (!queries("CREATE TABLE " . table($table != "" ? "adminer_$name" : $name) . " (\n" . implode(",\n", $fields) . "\n)")) {
index 62f1f488b1b8e6ee4af9bca613bfa7440415c119..7ad8f38f6702fcd808cc0c0ad19c623ee2026a6b 100644 (file)
@@ -1,6 +1,7 @@
 Adminer 4.0.3-dev:
 MongoDB: insert, truncate, indexes
 SimpleDB, MongoDB: insert more fields at once
+SQLite: Fix creating table and altering primary key, bug since Adminer 4.0.0
 Norweigan translation
 
 Adminer 4.0.2 (released 2014-01-11):