1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Move unsigned to Driver

This commit is contained in:
Jakub Vrana
2025-03-06 13:58:15 +01:00
parent 69d7d76dc5
commit a8feb00098
9 changed files with 8 additions and 13 deletions

View File

@@ -710,7 +710,6 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)) as $row
return array( return array(
'possible_drivers' => array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB"), 'possible_drivers' => array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB"),
'jush' => "mssql", 'jush' => "mssql",
'unsigned' => array(),
); );
} }
} }

View File

@@ -281,6 +281,7 @@ if (!defined("DRIVER")) {
class Driver extends SqlDriver { class Driver extends SqlDriver {
var $unsigned = array("unsigned", "zerofill", "unsigned zerofill");
var $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"); var $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL");
var $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"); var $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
var $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"); var $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
@@ -1197,13 +1198,12 @@ if (!defined("DRIVER")) {
} }
/** Get driver config /** Get driver config
* @return array ['possible_drivers' => , 'jush' => , 'unsigned' => ] * @return array ['possible_drivers' => , 'jush' => ]
*/ */
function driver_config() { function driver_config() {
return array( return array(
'possible_drivers' => array("MySQLi", "MySQL", "PDO_MySQL"), 'possible_drivers' => array("MySQLi", "MySQL", "PDO_MySQL"),
'jush' => "sql", ///< @var string JUSH identifier 'jush' => "sql", ///< @var string JUSH identifier
'unsigned' => array("unsigned", "zerofill", "unsigned zerofill"), ///< @var array number variants
); );
} }
} }

View File

@@ -549,7 +549,6 @@ ORDER BY PROCESS
return array( return array(
'possible_drivers' => array("OCI8", "PDO_OCI"), 'possible_drivers' => array("OCI8", "PDO_OCI"),
'jush' => "oracle", 'jush' => "oracle",
'unsigned' => array(),
); );
} }
} }

View File

@@ -940,7 +940,6 @@ AND typelem = 0"
return array( return array(
'possible_drivers' => array("PgSQL", "PDO_PgSQL"), 'possible_drivers' => array("PgSQL", "PDO_PgSQL"),
'jush' => "pgsql", 'jush' => "pgsql",
'unsigned' => array(),
); );
} }
} }

View File

@@ -742,7 +742,6 @@ if (isset($_GET["sqlite"])) {
return array( return array(
'possible_drivers' => array("SQLite3", "PDO_SQLite"), 'possible_drivers' => array("SQLite3", "PDO_SQLite"),
'jush' => "sqlite", 'jush' => "sqlite",
'unsigned' => array(),
); );
} }
} }

View File

@@ -35,7 +35,7 @@ if ($_GET["script"] == "version") {
exit; exit;
} }
global $adminer, $connection, $driver, $drivers, $enum_length, $error, $HTTPS, $inout, $jush, $LANG, $langs, $on_actions, $permanent, $has_token, $token, $translations, $unsigned, $VERSION; // allows including Adminer inside a function global $adminer, $connection, $driver, $drivers, $enum_length, $error, $HTTPS, $inout, $jush, $LANG, $langs, $on_actions, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function
if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility
$_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"]; $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"];
@@ -82,7 +82,6 @@ $on_actions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; ///< @var strin
$config = driver_config(); $config = driver_config();
$possible_drivers = $config['possible_drivers']; $possible_drivers = $config['possible_drivers'];
$jush = $config['jush']; $jush = $config['jush'];
$unsigned = $config['unsigned'];
define("SERVER", $_GET[DRIVER]); // read from pgsql=localhost define("SERVER", $_GET[DRIVER]); // read from pgsql=localhost
define("DB", $_GET["db"]); // for the sake of speed and size define("DB", $_GET["db"]); // for the sake of speed and size

View File

@@ -26,6 +26,7 @@ abstract class SqlDriver {
var $_conn; var $_conn;
protected $types = array(); ///< @var array [$description => [$type => $maximum_unsigned_length, ...], ...] protected $types = array(); ///< @var array [$description => [$type => $maximum_unsigned_length, ...], ...]
var $editFunctions = array(); ///< @var array of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only var $editFunctions = array(); ///< @var array of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only
var $unsigned = array(); ///< @var array number variants
var $operators = array(); ///< @var array operators used in select var $operators = array(); ///< @var array operators used in select
var $functions = array(); ///< @var array functions used in select var $functions = array(); ///< @var array functions used in select
var $grouping = array(); ///< @var array grouping functions used in select var $grouping = array(); ///< @var array grouping functions used in select

View File

@@ -209,7 +209,7 @@ function json_row($key, $val = null) {
* @return null * @return null
*/ */
function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_types = array()) { function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_types = array()) {
global $driver, $unsigned, $on_actions; global $driver, $on_actions;
$type = $field["type"]; $type = $field["type"];
?><td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php ?><td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php
if ($type && !array_key_exists($type, $driver->types()) && !isset($foreign_keys[$type]) && !in_array($type, $extra_types)) { if ($type && !array_key_exists($type, $driver->types()) && !isset($foreign_keys[$type]) && !in_array($type, $extra_types)) {
@@ -227,7 +227,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_ty
<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?> <?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?>
aria-labelledby="label-length"><td class="options"><?php aria-labelledby="label-length"><td class="options"><?php
echo ($collations ? "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>' : ''); echo ($collations ? "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>' : '');
echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : ''); echo ($driver->unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($driver->unsigned, $field["unsigned"]) . '</select>' : '');
echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>'
. optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), (preg_match('~^CURRENT_TIMESTAMP~i', $field["on_update"]) ? "CURRENT_TIMESTAMP" : $field["on_update"])) . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), (preg_match('~^CURRENT_TIMESTAMP~i', $field["on_update"]) ? "CURRENT_TIMESTAMP" : $field["on_update"]))
. '</select>' : '' . '</select>' : ''
@@ -269,10 +269,10 @@ function process_length($length) {
* @return string * @return string
*/ */
function process_type($field, $collate = "COLLATE") { function process_type($field, $collate = "COLLATE") {
global $unsigned, $jush; global $driver, $jush;
return " $field[type]" return " $field[type]"
. process_length($field["length"]) . process_length($field["length"])
. (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "") . (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $driver->unsigned) ? " $field[unsigned]" : "")
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . ($jush == "mssql" ? $field["collation"] : q($field["collation"])) : "") . (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . ($jush == "mssql" ? $field["collation"] : q($field["collation"])) : "")
; ;
} }

View File

@@ -384,7 +384,6 @@ if (isset($_GET["clickhouse"])) {
function driver_config() { function driver_config() {
return array( return array(
'jush' => "clickhouse", 'jush' => "clickhouse",
'unsigned' => array(),
); );
} }
} }