1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-30 09:39:51 +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";
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();
}
}

View File

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

View File

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

View File

@@ -1188,8 +1188,9 @@ if (!defined("DRIVER")) {
'structured_types' => $structured_types,
'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
'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',
'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
'edit_functions' => array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only
array(

View File

@@ -541,6 +541,7 @@ ORDER BY PROCESS
'structured_types' => $structured_types,
'unsigned' => array(),
'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"),
'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"),
'edit_functions' => array(

View File

@@ -947,6 +947,7 @@ AND typelem = 0"
'structured_types' => $structured_types,
'unsigned' => array(),
'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' => '~*',
'functions' => array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper"),
'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),
'unsigned' => array(),
'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"),
'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"),
'edit_functions' => array(

View File

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

View File

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

View File

@@ -151,14 +151,6 @@ function get_driver($id) {
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
* @param string
* @param array

View File

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

View File

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

View File

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

View File

@@ -267,10 +267,6 @@ if (isset($_GET["elastic5"])) {
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"),
'jush' => "elastic",
'operators' => array("=", "must", "should", "must_not"),
'operator_like' => "should",
'functions' => array(),
'grouping' => array(),
'edit_functions' => array(array("json")),

View File

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

View File

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