]> git.joonet.de Git - adminer.git/commitdiff
Split editFunctions
authorJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 13:53:53 +0000 (14:53 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 14:41:38 +0000 (15:41 +0100)
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/adminer.inc.php
adminer/include/driver.inc.php
adminer/include/html.inc.php
plugins/drivers/elastic.php
plugins/drivers/imap.php
plugins/drivers/mongo.php

index 5263be2f4ee47247d4ff478512dc1805581e08f7..1dc2404306679e8c2bb735ffd88f6c7582214e30 100644 (file)
@@ -205,13 +205,10 @@ if (isset($_GET["mssql"])) {
                static array $possibleDrivers = array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB");
                static string $jush = "mssql";
 
+               public array $insertFunctions = array("date|time" => "getdate");
                public array $editFunctions = array(
-                       array(
-                               "date|time" => "getdate",
-                       ), array(
-                               "int|decimal|real|float|money|datetime" => "+/-",
-                               "char|text" => "+",
-                       )
+                       "int|decimal|real|float|money|datetime" => "+/-",
+                       "char|text" => "+",
                );
 
                public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
index 54004940dc430ff157620e943f0be8066f2fb4f9..4925f7001c1e434f50eaa15f67cfe6d4dbe24983 100644 (file)
@@ -230,28 +230,27 @@ if (!defined('Adminer\DRIVER')) {
                                lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),
                                lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0),
                        );
+                       $this->insertFunctions = array(
+                               "char" => "md5/sha1/password/encrypt/uuid",
+                               "binary" => "md5/sha1",
+                               "date|time" => "now",
+                       );
                        $this->editFunctions = array(
-                               array(
-                                       "char" => "md5/sha1/password/encrypt/uuid",
-                                       "binary" => "md5/sha1",
-                                       "date|time" => "now",
-                               ), array(
-                                       number_type() => "+/-",
-                                       "date" => "+ interval/- interval",
-                                       "time" => "addtime/subtime",
-                                       "char|text" => "concat",
-                               )
+                               number_type() => "+/-",
+                               "date" => "+ interval/- interval",
+                               "time" => "addtime/subtime",
+                               "char|text" => "concat",
                        );
                        if (min_version('5.7.8', 10.2, $connection)) {
                                $this->types[lang('Strings')]["json"] = 4294967295;
                        }
                        if (min_version('', 10.7, $connection)) {
                                $this->types[lang('Strings')]["uuid"] = 128;
-                               $this->editFunctions[0]['uuid'] = 'uuid';
+                               $this->insertFunctions['uuid'] = 'uuid';
                        }
                        if (min_version(9, '', $connection)) {
                                $this->types[lang('Numbers')]["vector"] = 16383;
-                               $this->editFunctions[0]['vector'] = 'string_to_vector';
+                               $this->insertFunctions['vector'] = 'string_to_vector';
                        }
                        if (min_version(5.7, 10.2, $connection)) {
                                $this->generated = array("STORED", "VIRTUAL");
index 6c5940c87ffef7e253f79e3722d8714f6677c567..61b1134ca1056e532a6cdee524572cd2fb83dd23 100644 (file)
@@ -125,15 +125,14 @@ if (isset($_GET["oracle"])) {
                static array $possibleDrivers = array("OCI8", "PDO_OCI");
                static string $jush = "oracle";
 
+       public array $insertFunctions = array( //! no parentheses
+                       "date" => "current_date",
+                       "timestamp" => "current_timestamp",
+               );
                public array $editFunctions = array(
-                       array( //! no parentheses
-                               "date" => "current_date",
-                               "timestamp" => "current_timestamp",
-                       ), array(
-                               "number|float|double" => "+/-",
-                               "date|timestamp" => "+ interval/- interval",
-                               "char|clob" => "||",
-                       )
+                       "number|float|double" => "+/-",
+                       "date|timestamp" => "+ interval/- interval",
+                       "char|clob" => "||",
                );
 
                public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
index f2ee97219c50812fbeac095b1b4d705fa7e69175..32213ffc4c90d8d7517ca4df28d77998d5e66530 100644 (file)
@@ -192,15 +192,14 @@ if (isset($_GET["pgsql"])) {
                                        $this->types[lang('Strings')]["jsonb"] = 4294967295;
                                }
                        }
+                       $this->insertFunctions = array(
+                               "char" => "md5",
+                               "date|time" => "now",
+                       );
                        $this->editFunctions = array(
-                               array(
-                                       "char" => "md5",
-                                       "date|time" => "now",
-                               ), array(
-                                       number_type() => "+/-",
-                                       "date|time" => "+ interval/- interval", //! escape
-                                       "char|text" => "||",
-                               )
+                               number_type() => "+/-",
+                               "date|time" => "+ interval/- interval", //! escape
+                               "char|text" => "||",
                        );
                        if (min_version(12, 0, $connection)) {
                                $this->generated = array("STORED");
index 58c37cc49f60adb4a6a86cd541ff009f360fe637..ac23dce12f038d8157d0b6e70c7ff76f5c00d5dd 100644 (file)
@@ -111,14 +111,11 @@ if (isset($_GET["sqlite"])) {
 
                protected array $types = array(array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0));
 
+               public array $insertFunctions = array(); // "text" => "date('now')/time('now')/datetime('now')",
                public array $editFunctions = array(
-                       array(
-                               // "text" => "date('now')/time('now')/datetime('now')",
-                       ), array(
-                               "integer|real|numeric" => "+/-",
-                               // "text" => "date/time/datetime",
-                               "text" => "||",
-                       )
+                       "integer|real|numeric" => "+/-",
+                       // "text" => "date/time/datetime",
+                       "text" => "||",
                );
 
                public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function
index 94292fae581b68d1cf01501d22f24892b6c44366..0e5b21a75156198f600147b5eb40d1758489c35c 100644 (file)
@@ -672,7 +672,7 @@ class Adminer {
                global $driver;
                $return = ($field["null"] ? "NULL/" : "");
                $update = isset($_GET["select"]) || where($_GET);
-               foreach ($driver->editFunctions as $key => $functions) {
+               foreach (array($driver->insertFunctions, $driver->editFunctions) as $key => $functions) {
                        if (!$key || (!isset($_GET["call"]) && $update)) { // relative functions
                                foreach ($functions as $pattern => $val) {
                                        if (!$pattern || preg_match("~$pattern~", $field["type"])) {
@@ -680,7 +680,7 @@ class Adminer {
                                        }
                                }
                        }
-                       if ($key && !preg_match('~set|blob|bytea|raw|file|bool~', $field["type"])) {
+                       if ($key && $functions && !preg_match('~set|blob|bytea|raw|file|bool~', $field["type"])) {
                                $return .= "/SQL";
                        }
                }
index cc99fa732586c890d914dd84010aab4efe101fc9..e21c3c5731fc29d97a5ab24f660cd61305baf40c 100644 (file)
@@ -21,7 +21,8 @@ abstract class SqlDriver {
 
        protected Db $conn;
        /** @var int[][] */ protected array $types = array(); // [$group => [$type => $maximum_unsigned_length, ...], ...]
-       /** @var array{0?:string[], 1?:string[]} */ public array $editFunctions = array(); // of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only
+       /** @var string[] */ public array $insertFunctions = array(); // ["$type|$type2" => "$function/$function2"] functions used in edit and insert
+       /** @var string[] */ public array $editFunctions = array(); // ["$type|$type2" => "$function/$function2"] functions used in edit only
        /** @var list<string> */ public array $unsigned = array(); // number variants
        /** @var list<string> */ public array $operators = array(); // operators used in select
        /** @var list<string> */ public array $functions = array(); // functions used in select
index 9f3deda62d38aba973c2ca19db05249c77a2696e..c91e650a00160369ddc20b7cd1a5273a9a86da44 100644 (file)
@@ -191,7 +191,7 @@ function enum_input(string $type, string $attrs, array $field, $value, string $e
 * @param Field|RoutineField $field
 * @param mixed $value
 */
-function input(array $field, $value, string $function, ?bool $autofocus = false): void {
+function input(array $field, $value, ?string $function, ?bool $autofocus = false): void {
        global $driver, $adminer;
        $name = h(bracket_escape($field["field"]));
        echo "<td class='function'>";
index 2eb7ad0c423dac115d46c7ec041e02b5cf33d898..4f25890daacd8b878658f5a05f84222a80c10d58 100644 (file)
@@ -104,7 +104,7 @@ if (isset($_GET["elastic"])) {
                static array $possibleDrivers = array("json + allow_url_fopen");
                static string $jush = "elastic";
 
-               public array $editFunctions = array(array("json"));
+               public array $insertFunctions = array("json");
                public array $operators = array("=", "must", "should", "must_not");
 
                function __construct(Db $connection) {
index 2063bcab53b9006e2723a52b31d2f846df3da503..b30791a01b6475b759b9a2916152c403b16e697a 100644 (file)
@@ -145,7 +145,7 @@ if (isset($_GET["imap"])) {
        class Driver extends SqlDriver {
                static array $possibleDrivers = array("imap");
                static string $jush = "imap";
-               public array $editFunctions = array(array("json"));
+               public array $insertFunctions = array("json");
        }
 
        function logged_user() {
index d64527f7d8e581c64fc7383eca9346d8ef4a3eb4..fefcdb094da6f0e2c2f5f29e517437ddfbb546d8 100644 (file)
@@ -296,7 +296,7 @@ if (isset($_GET["mongo"])) {
                static array $possibleDrivers = array("mongodb");
                static string $jush = "mongo";
 
-               public array $editFunctions = array(array("json"));
+               public array $insertFunctions = array("json");
 
                public array $operators = array(
                        "=",