Use primary key instead of LIMIT 1 if available
This commit is contained in:
parent
d2ed0f7810
commit
89ceb06208
|
@ -246,7 +246,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||
global $connection;
|
||||
return (preg_match('~^INTO~', $query) || $connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')")
|
||||
? limit($query, $where, 1, 0, $separator)
|
||||
: " $query WHERE rowid = (SELECT rowid FROM " . table($table) . $where . $separator . "LIMIT 1)"
|
||||
: " $query WHERE rowid = (SELECT rowid FROM " . table($table) . $where . $separator . "LIMIT 1)" //! use primary key in tables with WITHOUT rowid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?php
|
||||
$VERSION = "4.6.0";
|
||||
$VERSION = "4.6.1-dev";
|
||||
|
|
|
@ -54,7 +54,7 @@ foreach ($indexes as $index) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ($oid && $unselected === null) {
|
||||
if ($oid && !$primary) {
|
||||
$primary = $unselected = array($oid => 0);
|
||||
$indexes[] = array("type" => "PRIMARY", "columns" => array($oid));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ if ($_POST && !$error) {
|
|||
. convert_fields($columns, $fields, $select)
|
||||
. "\nFROM " . table($TABLE);
|
||||
$group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
|
||||
if (!is_array($_POST["check"]) || $unselected === array()) {
|
||||
if (!is_array($_POST["check"]) || $primary) {
|
||||
$query = "SELECT $from$where_check$group_by";
|
||||
} else {
|
||||
$union = array();
|
||||
|
@ -108,7 +108,7 @@ if ($_POST && !$error) {
|
|||
if ($_POST["clone"]) {
|
||||
$query = "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE);
|
||||
}
|
||||
if ($_POST["all"] || ($unselected === array() && is_array($_POST["check"])) || $is_group) {
|
||||
if ($_POST["all"] || ($primary && is_array($_POST["check"])) || $is_group) {
|
||||
$result = ($_POST["delete"]
|
||||
? $driver->delete($TABLE, $where_check)
|
||||
: ($_POST["clone"]
|
||||
|
@ -165,7 +165,7 @@ if ($_POST && !$error) {
|
|||
$TABLE,
|
||||
$set,
|
||||
" WHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($unique_idf, $fields),
|
||||
!($is_group || $unselected === array()),
|
||||
!$is_group && !$primary,
|
||||
" "
|
||||
);
|
||||
if (!$result) {
|
||||
|
|
Loading…
Reference in a new issue