Editor: Cast to string when searching (bug #325)

This commit is contained in:
Jakub Vrana 2021-02-06 16:11:21 +01:00
parent ee75df6f15
commit cc9ed0939c
2 changed files with 4 additions and 2 deletions

View file

@ -8,6 +8,7 @@ PostgreSQL: Do not show view definition from other schema (PR #392)
PostgreSQL: Use bigserial for bigint auto increment (bug #765, regression from 3.0.0) PostgreSQL: Use bigserial for bigint auto increment (bug #765, regression from 3.0.0)
PostgreSQL 10: Support GENERATED ALWAYS BY IDENTITY (PR #386) PostgreSQL 10: Support GENERATED ALWAYS BY IDENTITY (PR #386)
MS SQL: Don't truncate comments to 30 chars (PR #376) MS SQL: Don't truncate comments to 30 chars (PR #376)
Editor: Cast to string when searching (bug #325)
Re-enable PHP warnings (regression from 4.7.8) Re-enable PHP warnings (regression from 4.7.8)
Adminer 4.7.8 (released 2020-12-06): Adminer 4.7.8 (released 2020-12-06):

View file

@ -341,6 +341,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
} }
function selectSearchProcess($fields, $indexes) { function selectSearchProcess($fields, $indexes) {
global $driver;
$return = array(); $return = array();
foreach ((array) $_GET["where"] as $key => $where) { foreach ((array) $_GET["where"] as $key => $where) {
$col = $where["col"]; $col = $where["col"];
@ -356,11 +357,11 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
} else { } else {
$text_type = preg_match('~char|text|enum|set~', $field["type"]); $text_type = preg_match('~char|text|enum|set~', $field["type"]);
$value = $this->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val)); $value = $this->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val));
$conds[] = $name . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value" $conds[] = $driver->convertSearch($name, $val, $field) . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
: (in_array($op, $this->operators) || $op == "=" ? " $op $value" : (in_array($op, $this->operators) || $op == "=" ? " $op $value"
: ($text_type ? " LIKE $value" : ($text_type ? " LIKE $value"
: " IN (" . str_replace(",", "', '", $value) . ")" : " IN (" . str_replace(",", "', '", $value) . ")"
))); //! can issue "Illegal mix of collations" for columns in other character sets - solve by CONVERT($name using utf8) )));
if ($key < 0 && $val == "0") { if ($key < 0 && $val == "0") {
$conds[] = "$name IS NULL"; $conds[] = "$name IS NULL";
} }