From cc9ed0939cc5a79bab15f62a65a1161335df002c Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 6 Feb 2021 16:11:21 +0100 Subject: [PATCH] Editor: Cast to string when searching (bug #325) --- changes.txt | 1 + editor/include/adminer.inc.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changes.txt b/changes.txt index 8dc013f7..bd22131b 100644 --- a/changes.txt +++ b/changes.txt @@ -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 10: Support GENERATED ALWAYS BY IDENTITY (PR #386) 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) Adminer 4.7.8 (released 2020-12-06): diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 16bb888a..ae9b0843 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -341,6 +341,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 } function selectSearchProcess($fields, $indexes) { + global $driver; $return = array(); foreach ((array) $_GET["where"] as $key => $where) { $col = $where["col"]; @@ -356,11 +357,11 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 } else { $text_type = preg_match('~char|text|enum|set~', $field["type"]); $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" : ($text_type ? " LIKE $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") { $conds[] = "$name IS NULL"; }