Skip to content

Commit

Permalink
Editor: Cast to string when searching (bug #325)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Feb 6, 2021
1 parent ee75df6 commit cc9ed09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes.txt
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions editor/include/adminer.inc.php
Expand Up @@ -341,6 +341,7 @@ function selectColumnsProcess($columns, $indexes) {
}

function selectSearchProcess($fields, $indexes) {
global $driver;
$return = array();
foreach ((array) $_GET["where"] as $key => $where) {
$col = $where["col"];
Expand All @@ -356,11 +357,11 @@ function selectSearchProcess($fields, $indexes) {
} 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";
}
Expand Down

0 comments on commit cc9ed09

Please sign in to comment.