]> git.joonet.de Git - adminer.git/commitdiff
Editor: Fix bit and enum search (fix #1062)
authorJakub Vrana <jakub@vrana.cz>
Sun, 4 May 2025 11:57:43 +0000 (13:57 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 4 May 2025 13:20:11 +0000 (15:20 +0200)
CHANGELOG.md
editor/include/adminer.inc.php

index 8ff8837566ed4a3cbd410a7182254bc2f8d7d300..872f03f0cc7dad958cef794e1f30bd6d19429724 100644 (file)
@@ -12,6 +12,7 @@
 - PostgreSQL: Support partial indices (bug #1048)
 - PostgreSQL: Support calling functions returning table (bug #1040)
 - PostgreSQL: Add NOT ILIKE operator (bug #1066)
+- Editor: Fix bit and enum search (bug #1062)
 - Designs: adminer.css with 'prefers-color-scheme: dark' doesn't disable dark mode
 - Plugins: Method bodyClass() to add &lt;body class>
 - Plugins: Allow setting dark mode in css()
index c66e5ceaa1d82166290839fdd8789e942c744ee9..6df24dcfe9bb3c6814d5fd5808175ffa90bc82c3 100644 (file)
@@ -264,10 +264,11 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
                        if (preg_match("~enum~", $field["type"]) || like_bool($field)) { //! set - uses 1 << $i and FIND_IN_SET()
                                $key = $keys[$name];
                                $i--;
-                               echo "<div>" . h($desc) . input_hidden("where[$i][col]", $name) . ":";
+                               echo "<div>" . h($desc) . ":" . input_hidden("where[$i][col]", $name);
+                               $val = idx($where[$key], "val");
                                echo (like_bool($field)
-                                       ? " <select name='where[$i][val]'>" . optionlist(array("" => "", lang('no'), lang('yes')), $where[$key]["val"], true) . "</select>"
-                                       : enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"], ($field["null"] ? 0 : null))
+                                       ? "<select name='where[$i][val]'>" . optionlist(array("" => "", lang('no'), lang('yes')), $val, true) . "</select>"
+                                       : enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $val, ($field["null"] ? 0 : null))
                                );
                                echo "</div>\n";
                                unset($columns[$name]);
@@ -365,14 +366,14 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
                                        if ($col != "" || is_numeric($val) || !preg_match(number_type(), $field["type"])) {
                                                $name = idf_escape($name);
                                                if ($col != "" && $field["type"] == "enum") {
-                                                       $conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
+                                                       $conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('Adminer\q', $val)) . ")";
                                                } else {
                                                        $text_type = preg_match('~char|text|enum|set~', $field["type"]);
                                                        $value = adminer()->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val));
                                                        $conds[] = driver()->convertSearch($name, $where, $field) . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
                                                                : (in_array($op, adminer()->operators()) || $op == "=" ? " $op $value"
                                                                : ($text_type ? " LIKE $value"
-                                                               : " IN (" . str_replace(",", "', '", $value) . ")"
+                                                               : " IN (" . ($value[0] == "'" ? str_replace(",", "', '", $value) : $value) . ")"
                                                        )));
                                                        if ($key < 0 && $val == "0") {
                                                                $conds[] = "$name IS NULL";
@@ -500,7 +501,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
                if (preg_match('~date|timestamp~', $field["type"]) && preg_match('(^' . str_replace('\$1', '(?P<p1>\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\2>\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) {
                        $return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match);
                }
-               $return = ($field["type"] == "bit" && preg_match('~^[0-9]+$~', $value) ? $return : q($return));
+               $return = q($return);
                if ($value == "" && like_bool($field)) {
                        $return = "'0'";
                } elseif ($value == "" && ($field["null"] || !preg_match('~char|text~', $field["type"]))) {