You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-23 18:29:15 +03:00
Add LIMIT 0 when fetching metadata
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
@@ -806,15 +806,15 @@ class DatabaseInterface implements DbalInterface
|
||||
/**
|
||||
* returns detailed array with all columns for sql
|
||||
*
|
||||
* @param string $sql_query target SQL query to get columns
|
||||
* @param string $sqlQuery target SQL query to get columns
|
||||
* @param array $view_columns alias for columns
|
||||
*
|
||||
* @return array
|
||||
* @psalm-return list<array<string, mixed>>
|
||||
*/
|
||||
public function getColumnMapFromSql(string $sql_query, array $view_columns = []): array
|
||||
public function getColumnMapFromSql(string $sqlQuery, array $view_columns = []): array
|
||||
{
|
||||
$result = $this->tryQuery($sql_query);
|
||||
$result = $this->tryQuery('SELECT * FROM (' . $sqlQuery . ') AS tmp LIMIT 0');
|
||||
|
||||
if ($result === false) {
|
||||
return [];
|
||||
|
||||
@@ -149,12 +149,12 @@ interface DbalInterface
|
||||
/**
|
||||
* returns detailed array with all columns for sql
|
||||
*
|
||||
* @param string $sql_query target SQL query to get columns
|
||||
* @param string $sqlQuery target SQL query to get columns
|
||||
* @param array $view_columns alias for columns
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnMapFromSql(string $sql_query, array $view_columns = []): array;
|
||||
public function getColumnMapFromSql(string $sqlQuery, array $view_columns = []): array;
|
||||
|
||||
/**
|
||||
* returns detailed array with all columns for given table in database,
|
||||
|
||||
@@ -1722,7 +1722,7 @@ class Table implements Stringable
|
||||
public function getColumnsMeta(): array
|
||||
{
|
||||
$moveColumnsSqlQuery = sprintf(
|
||||
'SELECT * FROM %s.%s LIMIT 1',
|
||||
'SELECT * FROM %s.%s LIMIT 0',
|
||||
Util::backquote($this->dbName),
|
||||
Util::backquote($this->name)
|
||||
);
|
||||
|
||||
@@ -186,7 +186,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
public function testPMAGetColumnMap(): void
|
||||
{
|
||||
$this->dummyDbi->addResult(
|
||||
'PMA_sql_query',
|
||||
'SELECT * FROM (PMA_sql_query) AS tmp LIMIT 0',
|
||||
[true],
|
||||
[],
|
||||
[
|
||||
|
||||
@@ -128,7 +128,7 @@ class ServerRequestFactoryTest extends AbstractTestCase
|
||||
return ['Content-Type' => 'application/x-www-form-urlencoded'];
|
||||
});
|
||||
|
||||
$method = (new ReflectionMethod(ServerRequestFactory::class, 'createServerRequestFromGlobals'));
|
||||
$method = new ReflectionMethod(ServerRequestFactory::class, 'createServerRequestFromGlobals');
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
$method->setAccessible(true);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class ServerRequestFactoryTest extends AbstractTestCase
|
||||
#[DataProvider('providerCreateUriFromGlobals')]
|
||||
public function testCreateUriFromGlobals(string $expected, array $server): void
|
||||
{
|
||||
$createUriFromGlobals = (new ReflectionMethod(ServerRequestFactory::class, 'createUriFromGlobals'));
|
||||
$createUriFromGlobals = new ReflectionMethod(ServerRequestFactory::class, 'createUriFromGlobals');
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
$createUriFromGlobals->setAccessible(true);
|
||||
}
|
||||
|
||||
@@ -2327,7 +2327,7 @@ class DbiDummy implements DbiExtension
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT * FROM `testdb`.`mytable` LIMIT 1',
|
||||
'query' => 'SELECT * FROM `testdb`.`mytable` LIMIT 0',
|
||||
'columns' => ['aid', '_id'],
|
||||
'result' => [
|
||||
[
|
||||
|
||||
@@ -1301,7 +1301,7 @@ class TableTest extends AbstractTestCase
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with('SELECT * FROM `db`.`table` LIMIT 1')
|
||||
->with('SELECT * FROM `db`.`table` LIMIT 0')
|
||||
->willReturn($resultStub);
|
||||
|
||||
$dbi->expects($this->once())
|
||||
|
||||
Reference in New Issue
Block a user