Pull-request: #17775 Fixes: #17428 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
09259eb1a1
@ -164,7 +164,7 @@ final class Search
|
||||
// strings to numbers and numbers to strings as necessary
|
||||
// during the comparison
|
||||
if (
|
||||
preg_match('@char|binary|blob|text|set|date|time|year@i', $types)
|
||||
preg_match('@char|binary|blob|text|set|date|time|year|uuid@i', $types)
|
||||
|| mb_strpos(' ' . $func_type, 'LIKE')
|
||||
) {
|
||||
$quot = '\'';
|
||||
|
||||
@ -139,6 +139,25 @@ class Types
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* UUID search operators
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getUUIDOperators()
|
||||
{
|
||||
return [
|
||||
'=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'LIKE %...%',
|
||||
'NOT LIKE',
|
||||
'NOT LIKE %...%',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns operators for given type
|
||||
*
|
||||
@ -156,6 +175,8 @@ class Types
|
||||
$ret = array_merge($ret, $this->getEnumOperators());
|
||||
} elseif ($class === 'CHAR') {
|
||||
$ret = array_merge($ret, $this->getTextOperators());
|
||||
} elseif ($class === 'UUID') {
|
||||
$ret = array_merge($ret, $this->getUUIDOperators());
|
||||
} else {
|
||||
$ret = array_merge($ret, $this->getNumberOperators());
|
||||
}
|
||||
|
||||
@ -208,4 +208,34 @@ class SearchTest extends AbstractTestCase
|
||||
$this->search->buildSqlQuery()
|
||||
);
|
||||
}
|
||||
|
||||
public function testBuildSqlQueryWithWhereClauseUUID(): void
|
||||
{
|
||||
$_POST['zoom_submit'] = true;
|
||||
$_POST['table'] = 'PMA';
|
||||
|
||||
$this->assertEquals(
|
||||
'SELECT * FROM `PMA`',
|
||||
$this->search->buildSqlQuery()
|
||||
);
|
||||
|
||||
$_POST['customWhereClause'] = '';
|
||||
|
||||
$this->assertEquals(
|
||||
'SELECT * FROM `PMA`',
|
||||
$this->search->buildSqlQuery()
|
||||
);
|
||||
|
||||
unset($_POST['customWhereClause']);
|
||||
$_POST['criteriaColumnNames'] = ['id'];
|
||||
$_POST['criteriaColumnOperators'] = ['='];
|
||||
|
||||
$_POST['criteriaValues'] = ['07ca1fdd-4805-11ed-a4dc-0242ac110002'];
|
||||
$_POST['criteriaColumnTypes'] = ['uuid'];
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT * FROM `PMA` WHERE `id` = '07ca1fdd-4805-11ed-a4dc-0242ac110002'",
|
||||
$this->search->buildSqlQuery()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +130,26 @@ class TypesTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getUUIDOperators
|
||||
*/
|
||||
public function testGetUUIDOperators(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
'=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'LIKE %...%',
|
||||
'NOT LIKE',
|
||||
'NOT LIKE %...%',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
],
|
||||
$this->object->getUUIDOperators()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getting type operators
|
||||
*
|
||||
@ -194,6 +214,36 @@ class TypesTest extends AbstractTestCase
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'UUID',
|
||||
false,
|
||||
[
|
||||
'=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'LIKE %...%',
|
||||
'NOT LIKE',
|
||||
'NOT LIKE %...%',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
],
|
||||
],
|
||||
[
|
||||
'UUID',
|
||||
true,
|
||||
[
|
||||
'=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'LIKE %...%',
|
||||
'NOT LIKE',
|
||||
'NOT LIKE %...%',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
'IS NULL',
|
||||
'IS NOT NULL',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user