From 6cfb3676a7025cfa7299ecfb6a68d6cdc3aa343a Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 6 Feb 2018 12:17:01 +0100 Subject: [PATCH] PostgreSQL: Don't treat interval type as number (bug #474) --- adminer/drivers/mysql.inc.php | 2 +- adminer/drivers/pgsql.inc.php | 2 +- adminer/include/adminer.inc.php | 4 ++-- adminer/include/editing.inc.php | 4 ++-- adminer/include/functions.inc.php | 9 ++++++++- adminer/static/editing.js | 2 +- changes.txt | 3 +++ editor/include/adminer.inc.php | 4 ++-- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 2f93e099..34096740 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -1071,7 +1071,7 @@ if (!defined("DRIVER")) { "binary" => "md5/sha1", "date|time" => "now", ), array( - "(^|[^o])int|float|double|decimal" => "+/-", // not point + number_type() => "+/-", "date" => "+ interval/- interval", "time" => "addtime/subtime", "char|text" => "concat", diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 7eb5e903..57961c8c 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -789,7 +789,7 @@ AND typelem = 0" "char" => "md5", "date|time" => "now", ), array( - "int|numeric|real|money" => "+/-", + number_type() => "+/-", "date|time" => "+ interval/- interval", //! escape "char|text" => "||", ) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 85340477..4475d7ff 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -543,7 +543,7 @@ class Adminer { $cols = array(); foreach ($fields as $name => $field) { $is_text = preg_match('~char|text|enum|set~', $field["type"]); - if ((is_numeric($val["val"]) || !preg_match('~(^|[^o])int|float|double|decimal|bit~', $field["type"])) + if ((is_numeric($val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"])) && (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text) ) { $name = idf_escape($name); @@ -828,7 +828,7 @@ class Adminer { foreach ($row as $key => $val) { $field = $fields[$key]; $row[$key] = ($val !== null - ? unconvert_field($field, preg_match('~(^|[^o])int|float|double|decimal~', $field["type"]) && $val != '' ? $val : q($val)) + ? unconvert_field($field, preg_match('~' . number_type() . '~', $field["type"]) && $val != '' ? $val : q($val)) : "NULL" ); } diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 9a35a5e2..8fb46b21 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -155,7 +155,7 @@ echo optionlist(array_merge($extra_types, $structured_types), $type); " size="3" aria-labelledby="label-length">