mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 22:56:46 +02:00
Split editFunctions
This commit is contained in:
@@ -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");
|
||||
|
@@ -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");
|
||||
|
@@ -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");
|
||||
|
@@ -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");
|
||||
|
@@ -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
|
||||
|
@@ -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";
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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'>";
|
||||
|
@@ -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) {
|
||||
|
@@ -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() {
|
||||
|
@@ -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(
|
||||
"=",
|
||||
|
Reference in New Issue
Block a user