1
0
mirror of https://github.com/vrana/adminer.git synced 2025-09-01 18:32:39 +02:00

Define 'LIKE%%' operator in each driver

This commit is contained in:
Peter Knut
2024-10-11 23:01:28 +02:00
parent e378f7d817
commit 13752c0498
16 changed files with 24 additions and 24 deletions

View File

@@ -65,7 +65,7 @@ if ($adminer->homepage()) {
} }
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
if ($_POST["search"] && $_POST["query"] != "") { if ($_POST["search"] && $_POST["query"] != "") {
$_GET["where"][0]["op"] = $driver->convertOperator($adminer->operator_regexp !== null && !empty($_POST['regexp']) ? $adminer->operator_regexp : "LIKE %%"); $_GET["where"][0]["op"] = $adminer->operator_regexp !== null && !empty($_POST['regexp']) ? $adminer->operator_regexp : $adminer->operator_like;
search_tables(); search_tables();
} }
} }

View File

@@ -741,6 +741,7 @@ if (isset($_GET["mongo"])) {
'possible_drivers' => array("mongo", "mongodb"), 'possible_drivers' => array("mongo", "mongodb"),
'jush' => "mongo", 'jush' => "mongo",
'operators' => $operators, 'operators' => $operators,
'operator_like' => "LIKE %%", // TODO: LIKE operator is not listed in operators.
'operator_regexp' => $operator_regexp, 'operator_regexp' => $operator_regexp,
'functions' => array(), 'functions' => array(),
'grouping' => array(), 'grouping' => array(),

View File

@@ -675,6 +675,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
'structured_types' => $structured_types, 'structured_types' => $structured_types,
'unsigned' => array(), 'unsigned' => array(),
'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"), 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"),
'operator_like' => "LIKE %%",
'functions' => array("len", "lower", "round", "upper"), 'functions' => array("len", "lower", "round", "upper"),
'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"),
'edit_functions' => array( 'edit_functions' => array(

View File

@@ -1188,8 +1188,9 @@ if (!defined("DRIVER")) {
'structured_types' => $structured_types, 'structured_types' => $structured_types,
'unsigned' => array("unsigned", "zerofill", "unsigned zerofill"), ///< @var array number variants 'unsigned' => array("unsigned", "zerofill", "unsigned zerofill"), ///< @var array number variants
'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"), ///< @var array operators used in select 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"), ///< @var array operators used in select
'functions' => array("char_length", "date", "from_unixtime", "unix_timestamp", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"), ///< @var array functions used in select 'operator_like' => "LIKE %%",
'operator_regexp' => 'REGEXP', 'operator_regexp' => 'REGEXP',
'functions' => array("char_length", "date", "from_unixtime", "unix_timestamp", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"), ///< @var array functions used in select
'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"), ///< @var array grouping functions used in select 'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"), ///< @var array grouping functions used in select
'edit_functions' => array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only 'edit_functions' => array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only
array( array(

View File

@@ -541,6 +541,7 @@ ORDER BY PROCESS
'structured_types' => $structured_types, 'structured_types' => $structured_types,
'unsigned' => array(), 'unsigned' => array(),
'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"), 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"),
'operator_like' => "LIKE %%",
'functions' => array("length", "lower", "round", "upper"), 'functions' => array("length", "lower", "round", "upper"),
'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"),
'edit_functions' => array( 'edit_functions' => array(

View File

@@ -947,6 +947,7 @@ AND typelem = 0"
'structured_types' => $structured_types, 'structured_types' => $structured_types,
'unsigned' => array(), 'unsigned' => array(),
'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "~*", "!~", "!~*", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"), // no "SQL" to avoid CSRF 'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "~*", "!~", "!~*", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"), // no "SQL" to avoid CSRF
'operator_like' => "LIKE %%",
'operator_regexp' => '~*', 'operator_regexp' => '~*',
'functions' => array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper"), 'functions' => array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper"),
'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"),

View File

@@ -804,6 +804,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
'structured_types' => array_keys($types), 'structured_types' => array_keys($types),
'unsigned' => array(), 'unsigned' => array(),
'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"), // REGEXP can be user defined function 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"), // REGEXP can be user defined function
'operator_like' => "LIKE %%",
'functions' => array("hex", "length", "lower", "round", "unixepoch", "upper"), 'functions' => array("hex", "length", "lower", "round", "unixepoch", "upper"),
'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"), 'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"),
'edit_functions' => array( 'edit_functions' => array(

View File

@@ -4,6 +4,8 @@
class Adminer { class Adminer {
/** @var array operators used in select, null for all operators */ /** @var array operators used in select, null for all operators */
var $operators = null; var $operators = null;
/** @var string operator for LIKE condition */
var $operator_like = null;
/** @var string operator for regular expression condition */ /** @var string operator for regular expression condition */
var $operator_regexp = null; var $operator_regexp = null;

View File

@@ -93,6 +93,7 @@ $types = $config['types'];
$structured_types = $config['structured_types']; $structured_types = $config['structured_types'];
$unsigned = $config['unsigned']; $unsigned = $config['unsigned'];
$operators = $config['operators']; $operators = $config['operators'];
$operator_like = $config['operator_like'];
$operator_regexp = $config['operator_regexp']; $operator_regexp = $config['operator_regexp'];
$functions = $config['functions']; $functions = $config['functions'];
$grouping = $config['grouping']; $grouping = $config['grouping'];
@@ -100,6 +101,7 @@ $edit_functions = $config['edit_functions'];
if ($adminer->operators === null) { if ($adminer->operators === null) {
$adminer->operators = $operators; $adminer->operators = $operators;
$adminer->operator_like = $operator_like;
$adminer->operator_regexp = $operator_regexp; $adminer->operator_regexp = $operator_regexp;
} }

View File

@@ -151,14 +151,6 @@ function get_driver($id) {
return $idf; return $idf;
} }
/** Convert operator so it can be used in search
* @param string $operator
* @return string
*/
function convertOperator($operator) {
return $operator;
}
/** Convert value returned by database to actual value /** Convert value returned by database to actual value
* @param string * @param string
* @param array * @param array

View File

@@ -1,6 +1,7 @@
<?php <?php
class Adminer { class Adminer {
var $operators = array("<=", ">="); var $operators = array("<=", ">=");
var $operator_like = null;
var $operator_regexp = null; var $operator_regexp = null;
var $_values = array(); var $_values = array();

View File

@@ -427,6 +427,7 @@ if (isset($_GET["clickhouse"])) {
'structured_types' => $structured_types, 'structured_types' => $structured_types,
'unsigned' => array(), 'unsigned' => array(),
'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"), 'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"),
'operator_like' => "LIKE %%",
'functions' => array(), 'functions' => array(),
'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"),
'edit_functions' => array(), 'edit_functions' => array(),

View File

@@ -265,10 +265,6 @@ if (isset($_GET["elastic"])) {
return $this->_conn->affected_rows; return $this->_conn->affected_rows;
} }
function convertOperator($operator) {
return $operator == "LIKE %%" ? "should" : $operator;
}
} }
function connect() { function connect() {
@@ -581,6 +577,7 @@ if (isset($_GET["elastic"])) {
'possible_drivers' => array("json + allow_url_fopen"), 'possible_drivers' => array("json + allow_url_fopen"),
'jush' => "elastic", 'jush' => "elastic",
'operators' => array("=", "must", "should", "must_not"), 'operators' => array("=", "must", "should", "must_not"),
'operator_like' => "should",
'functions' => array(), 'functions' => array(),
'grouping' => array(), 'grouping' => array(),
'edit_functions' => array(array("json")), 'edit_functions' => array(array("json")),

View File

@@ -267,10 +267,6 @@ if (isset($_GET["elastic5"])) {
return $this->_conn->affected_rows; return $this->_conn->affected_rows;
} }
function convertOperator($operator) {
return $operator == "LIKE %%" ? "should" : $operator;
}
} }
/** /**
@@ -561,6 +557,7 @@ if (isset($_GET["elastic5"])) {
'possible_drivers' => array("json + allow_url_fopen"), 'possible_drivers' => array("json + allow_url_fopen"),
'jush' => "elastic", 'jush' => "elastic",
'operators' => array("=", "must", "should", "must_not"), 'operators' => array("=", "must", "should", "must_not"),
'operator_like' => "should",
'functions' => array(), 'functions' => array(),
'grouping' => array(), 'grouping' => array(),
'edit_functions' => array(array("json")), 'edit_functions' => array(array("json")),

View File

@@ -20,7 +20,7 @@ if (isset($_GET["firebird"])) {
; ;
function connect($server, $username, $password) { function connect($server, $username, $password) {
$this->_link = ibase_connect($server, $username, $password); $this->_link = ibase_connect($server, $username, $password);
if ($this->_link) { if ($this->_link) {
$url_parts = explode(':', $server); $url_parts = explode(':', $server);
$this->service_link = ibase_service_attach($url_parts[0], $username, $password); $this->service_link = ibase_service_attach($url_parts[0], $username, $password);
@@ -109,9 +109,9 @@ if (isset($_GET["firebird"])) {
} }
} }
class Min_Driver extends Min_SQL { class Min_Driver extends Min_SQL {
} }
@@ -140,7 +140,7 @@ if (isset($_GET["firebird"])) {
} }
function limit($query, $where, $limit, $offset = 0, $separator = " ") { function limit($query, $where, $limit, $offset = 0, $separator = " ") {
$return = ''; $return = '';
$return .= ($limit !== null ? $separator . "FIRST $limit" . ($offset ? " SKIP $offset" : "") : ""); $return .= ($limit !== null ? $separator . "FIRST $limit" . ($offset ? " SKIP $offset" : "") : "");
$return .= " $query$where"; $return .= " $query$where";
return $return; return $return;
@@ -171,7 +171,7 @@ if (isset($_GET["firebird"])) {
while ($row = ibase_fetch_assoc($result)) { while ($row = ibase_fetch_assoc($result)) {
$return[$row['RDB$RELATION_NAME']] = 'table'; $return[$row['RDB$RELATION_NAME']] = 'table';
} }
ksort($return); ksort($return);
return $return; return $return;
} }
@@ -316,6 +316,7 @@ ORDER BY RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION';
'possible_drivers' => array("interbase"), 'possible_drivers' => array("interbase"),
'jush' => "firebird", 'jush' => "firebird",
'operators' => array("="), 'operators' => array("="),
'operator_like' => "LIKE %%", // TODO: LIKE operator is not listed in operators.
'functions' => array(), 'functions' => array(),
'grouping' => array(), 'grouping' => array(),
'edit_functions' => array(), 'edit_functions' => array(),

View File

@@ -514,6 +514,7 @@ if (isset($_GET["simpledb"])) {
'possible_drivers' => array("SimpleXML + allow_url_fopen"), 'possible_drivers' => array("SimpleXML + allow_url_fopen"),
'jush' => "simpledb", 'jush' => "simpledb",
'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL"), 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL"),
'operator_like' => "LIKE %%",
'functions' => array(), 'functions' => array(),
'grouping' => array("count"), 'grouping' => array("count"),
'edit_functions' => array(array("json")), 'edit_functions' => array(array("json")),