Menu

#607 Adminer Editor: Missing booelan support on PostgreSQL

4.6.2
closed-fixed
nobody
None
5
2018-05-06
2018-03-24
Jan Tojnar
No

Adminer Editor does not support booleans on PostgreSQL. The following patch seems to fix it but did not test it with other drivers.

--- a/adminer/include/functions.inc.php
+++ b/adminer/include/functions.inc.php
@@ -181,7 +181,7 @@

 * @return string
 */
 function checkbox($name, $value, $checked, $label = "", $onclick = "", $class = "", $labelled_by = "") {
-   $return = "<input type='checkbox' name='$name' value='" . h($value) . "'"
+   $return = "<input type='checkbox' name='$name' value='1'"
        . ($checked ? " checked" : "")
        . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
        . ">"
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -484,7 +484,7 @@
            );
        }
        if (like_bool($field)) {
-           return '<input type="checkbox" value="' . h($value ? $value : 1) . '"' . ($value ? ' checked' : '') . "$attrs>";
+           return '<input type="checkbox" value="' . h($value ? $value : 1) . '"' . (preg_match('~^(1|t|true|y|yes|on)$~i', $value) ? " checked='checked'" : "") . "$attrs>";
        }
        $hint = "";
        if (preg_match('~time~', $field["type"])) {
@@ -516,7 +516,7 @@
        }
        $return = ($field["type"] == "bit" && preg_match('~^[0-9]+$~', $value) ? $return : q($return));
        if ($value == "" && like_bool($field)) {
-           $return = "0";
+           $return = false;
        } elseif ($value == "" && ($field["null"] || !preg_match('~char|text~', $field["type"]))) {
            $return = "NULL";
        } elseif (preg_match('~^(md5|sha1)$~', $function)) {

Discussion

  • Jakub Vrána

    Jakub Vrána - 2018-05-06
    • status: open --> closed-fixed
     
  • Jakub Vrána

    Jakub Vrána - 2018-05-06

    I've included the preg_match part, others seem not required.

     

Log in to post a comment.

Auth0 Logo