Permalink
Browse files

SQLite: Better editing in tables without a primary key

  • Loading branch information...
1 parent c2f95e0 commit 98483e101d5a672ebfd49e4076ab51b812d5fec5 @vrana committed Jul 15, 2012
Showing with 7 additions and 3 deletions.
  1. +1 −0 adminer/drivers/sqlite.inc.php
  2. +5 −3 adminer/select.inc.php
  3. +1 −0 changes.txt
@@ -252,6 +252,7 @@ function count_tables($databases) {
function table_status($name = "") {
$return = array();
foreach (get_rows("SELECT name AS Name, type AS Engine FROM sqlite_master WHERE type IN ('table', 'view')" . ($name != "" ? " AND name = " . q($name) : "")) as $row) {
+ $row["Oid"] = "t";
$row["Auto_increment"] = "";
$return[$row["Name"]] = $row;
}
View
@@ -4,8 +4,10 @@
$indexes = indexes($TABLE);
$fields = fields($TABLE);
$foreign_keys = column_foreign_keys($TABLE);
+$oid = "";
if ($table_status["Oid"] == "t") {
- $indexes[] = array("type" => "PRIMARY", "columns" => array("oid"));
+ $oid = ($jush == "sqlite" ? "rowid" : "oid");
+ $indexes[] = array("type" => "PRIMARY", "columns" => array($oid));
}
parse_str($_COOKIE["adminer_import"], $adminer_import);
@@ -27,7 +29,7 @@
$where = $adminer->selectSearchProcess($fields, $indexes);
$order = $adminer->selectOrderProcess($fields, $indexes);
$limit = $adminer->selectLimitProcess();
-$from = ($select ? implode(", ", $select) : ($table_status["Oid"] == "t" ? "oid, " : "") . "*") . "\nFROM " . table($TABLE);
+$from = ($select ? implode(", ", $select) : ($oid ? "$oid, " : "") . "*") . "\nFROM " . table($TABLE);
$group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
if ($_GET["val"] && is_ajax()) {
@@ -257,7 +259,7 @@
reset($select);
$rank = 1;
foreach ($rows[0] as $key => $val) {
- if ($table_status["Oid"] != "t" || $key != "oid") {
+ if ($key != $oid) {
$val = $_GET["columns"][key($select)];
$field = $fields[$select ? ($val ? $val["col"] : current($select)) : $key];
$name = ($field ? $adminer->fieldName($field, $rank) : "*");
View
@@ -1,5 +1,6 @@
Adminer 3.4.1-dev:
SQLite: Full alter table
+SQLite: Better editing in tables without a primary key
Adminer 3.4.0 (released 2012-06-30):
Link to descending order

0 comments on commit 98483e1

Please sign in to comment.