Merge ColumnFull & Column
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
b28b32e424
commit
6909ef45b3
@ -5560,7 +5560,7 @@ parameters:
|
||||
path: src/Database/CentralColumns.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$def of method PhpMyAdmin\\Database\\CentralColumns\:\:getInsertQuery\(\) expects PhpMyAdmin\\ColumnFull, PhpMyAdmin\\ColumnFull\|null given\.$#'
|
||||
message: '#^Parameter \#1 \$def of method PhpMyAdmin\\Database\\CentralColumns\:\:getInsertQuery\(\) expects PhpMyAdmin\\Column, PhpMyAdmin\\Column\|null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Database/CentralColumns.php
|
||||
@ -20040,12 +20040,36 @@ parameters:
|
||||
count: 9
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Class PhpMyAdmin\\Column constructor invoked with 6 parameters, 9 required\.$#'
|
||||
identifier: arguments.count
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$collation of class PhpMyAdmin\\Column constructor expects string\|null, false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#4 \$isNull of class PhpMyAdmin\\Column constructor expects bool, string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#5 \$key of class PhpMyAdmin\\Column constructor expects string, null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: 80, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#'
|
||||
identifier: assign.propertyType
|
||||
|
||||
@ -2359,9 +2359,6 @@
|
||||
</PossiblyUnusedReturnValue>
|
||||
</file>
|
||||
<file src="src/Controllers/Table/CreateController.php">
|
||||
<ImplicitToStringCast>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
</ImplicitToStringCast>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$_POST['field_input_transformation'][$fieldindex]]]></code>
|
||||
<code><![CDATA[$_POST['field_input_transformation_options'][$fieldindex]]]></code>
|
||||
@ -2381,6 +2378,7 @@
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyInvalidArrayOffset>
|
||||
<code><![CDATA[$_POST['field_input_transformation'][$fieldindex]]]></code>
|
||||
@ -2536,15 +2534,13 @@
|
||||
</PossiblyUnusedReturnValue>
|
||||
</file>
|
||||
<file src="src/Controllers/Table/GetFieldController.php">
|
||||
<ImplicitToStringCast>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
</ImplicitToStringCast>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
<code><![CDATA[Current::$table]]></code>
|
||||
</MixedArgument>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
<code><![CDATA[Current::$database]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
</file>
|
||||
<file src="src/Controllers/Table/GisVisualizationController.php">
|
||||
@ -4022,7 +4018,7 @@
|
||||
* Visible?: string,
|
||||
* Expression?: string|null
|
||||
* }>]]></code>
|
||||
<code><![CDATA[array_column($result->fetchAllAssoc(), 'Field')]]></code>
|
||||
<code><![CDATA[array_column($result->fetchAllAssoc(), 'COLUMN_NAME')]]></code>
|
||||
<code><![CDATA[list<string>]]></code>
|
||||
</MixedReturnTypeCoercion>
|
||||
<NullableReturnStatement>
|
||||
@ -12319,6 +12315,10 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidArgument>
|
||||
<code><![CDATA['']]></code>
|
||||
<code><![CDATA[false]]></code>
|
||||
</InvalidArgument>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$config->selectedServer]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
@ -12329,6 +12329,14 @@
|
||||
<code><![CDATA[$result]]></code>
|
||||
<code><![CDATA[$result]]></code>
|
||||
</MixedAssignment>
|
||||
<NullArgument>
|
||||
<code><![CDATA[null]]></code>
|
||||
</NullArgument>
|
||||
<TooFewArguments>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
</TooFewArguments>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Export/ExportTexytextTest.php">
|
||||
<DeprecatedMethod>
|
||||
|
||||
@ -9,10 +9,13 @@ final readonly class Column
|
||||
public function __construct(
|
||||
public string $field,
|
||||
public string $type,
|
||||
public string|null $collation,
|
||||
public bool $isNull,
|
||||
public string $key,
|
||||
public string|null $default,
|
||||
public string $extra,
|
||||
public string $privileges,
|
||||
public string $comment,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
final readonly class ColumnFull
|
||||
{
|
||||
public function __construct(
|
||||
public string $field,
|
||||
public string $type,
|
||||
public string|null $collation,
|
||||
public bool $isNull,
|
||||
public string $key,
|
||||
public string|null $default,
|
||||
public string $extra,
|
||||
public string $privileges,
|
||||
public string $comment,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@ -529,7 +529,7 @@ class Relation
|
||||
$comments = [];
|
||||
|
||||
// MySQL native column comments
|
||||
$columns = $this->dbi->getColumns($db, $table, true);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
if ($column->comment === '') {
|
||||
continue;
|
||||
|
||||
@ -134,7 +134,7 @@ final class FindReplaceController implements InvocableController
|
||||
private function loadTableInfo(): void
|
||||
{
|
||||
// Gets the list and number of columns
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
|
||||
foreach ($columns as $row) {
|
||||
// set column name
|
||||
|
||||
@ -105,7 +105,7 @@ final class SearchController implements InvocableController
|
||||
private function loadTableInfo(): void
|
||||
{
|
||||
// Gets the list and number of columns
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
// Get details about the geometry functions
|
||||
$geomTypes = Gis::getDataTypes();
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Controllers\Table\Structure;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
@ -73,13 +73,13 @@ final class ChangeController implements InvocableController
|
||||
*/
|
||||
private function displayHtmlForColumnChange(array $selected): void
|
||||
{
|
||||
$fieldsMeta = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$fieldsMeta = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
$fieldsMeta = array_values(array_filter(
|
||||
$fieldsMeta,
|
||||
static fn (ColumnFull $column): bool => in_array($column->field, $selected, true),
|
||||
static fn (Column $column): bool => in_array($column->field, $selected, true),
|
||||
));
|
||||
// TODO: Refactor columnsDefinition->displayForm() method to avoid unwrapping DTO
|
||||
$fieldsMeta = array_map(static fn (ColumnFull $column): array => [
|
||||
$fieldsMeta = array_map(static fn (Column $column): array => [
|
||||
'Field' => $column->field,
|
||||
'Type' => $column->type,
|
||||
'Collation' => $column->collation,
|
||||
|
||||
@ -6,7 +6,7 @@ namespace PhpMyAdmin\Controllers\Table;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
@ -115,7 +115,7 @@ class StructureController implements InvocableController
|
||||
->getTable(Current::$database, Current::$table)
|
||||
->getColumnsWithIndex(Index::UNIQUE | Index::INDEX | Index::SPATIAL | Index::FULLTEXT);
|
||||
|
||||
$fields = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$fields = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
|
||||
$this->response->addHTML($this->displayStructure(
|
||||
$relationParameters,
|
||||
@ -132,7 +132,7 @@ class StructureController implements InvocableController
|
||||
/**
|
||||
* Displays the table structure ('show table' works correct since 3.23.03)
|
||||
*
|
||||
* @param ColumnFull[] $fields Fields
|
||||
* @param Column[] $fields Fields
|
||||
* @param (string|int)[] $columnsWithIndex Columns with index
|
||||
* @psalm-param non-empty-string $route
|
||||
*/
|
||||
|
||||
@ -193,7 +193,7 @@ final class ZoomSearchController implements InvocableController
|
||||
private function loadTableInfo(): void
|
||||
{
|
||||
// Gets the list and number of columns
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$columns = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
// Get details about the geometry functions
|
||||
$geomTypes = Gis::getDataTypes();
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Database;
|
||||
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
@ -212,15 +212,15 @@ class CentralColumns
|
||||
* build the insert query for central columns list given PMA storage
|
||||
* db, central_columns table, column name and corresponding definition to be added
|
||||
*
|
||||
* @param ColumnFull $def list of attributes of the column being added
|
||||
* @param string $db PMA configuration storage database name
|
||||
* @param string $centralListTable central columns configuration storage table name
|
||||
* @param Column $def list of attributes of the column being added
|
||||
* @param string $db PMA configuration storage database name
|
||||
* @param string $centralListTable central columns configuration storage table name
|
||||
*
|
||||
* @return string query string to insert the given column
|
||||
* with definition into central list
|
||||
*/
|
||||
private function getInsertQuery(
|
||||
ColumnFull $def,
|
||||
Column $def,
|
||||
string $db,
|
||||
string $centralListDb,
|
||||
string $centralListTable,
|
||||
@ -273,7 +273,7 @@ class CentralColumns
|
||||
$cols = [];
|
||||
$fields = [];
|
||||
foreach ($fieldSelect as $table) {
|
||||
$fields[$table] = $this->dbi->getColumns($databaseName->getName(), $table, true);
|
||||
$fields[$table] = $this->dbi->getColumns($databaseName->getName(), $table);
|
||||
$cols = array_merge($cols, array_column($fields[$table], 'field'));
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ class CentralColumns
|
||||
foreach ($fieldSelect as $column) {
|
||||
if (! in_array($column, $hasList, true)) {
|
||||
$hasList[] = $column;
|
||||
$field = $this->dbi->getColumn($databaseName->getName(), $containingTable, $column, true);
|
||||
$field = $this->dbi->getColumn($databaseName->getName(), $containingTable, $column);
|
||||
$insQuery[] = $this->getInsertQuery(
|
||||
$field,
|
||||
$databaseName->getName(),
|
||||
@ -529,7 +529,7 @@ class CentralColumns
|
||||
$centralListDb = $cfgCentralColumns['db'];
|
||||
$centralTable = $cfgCentralColumns['table'];
|
||||
if ($origColName === '') {
|
||||
$def = new ColumnFull(
|
||||
$def = new Column(
|
||||
$colName,
|
||||
$colType . ($colLength !== '' ? '(' . $colLength . ')' : ''),
|
||||
$collation,
|
||||
|
||||
@ -83,16 +83,16 @@ class Common
|
||||
|
||||
foreach ($designerTables as $designerTable) {
|
||||
$fieldsRs = $this->dbi->query(
|
||||
QueryGenerator::getColumnsSql(
|
||||
$designerTable->getDatabaseName(),
|
||||
$designerTable->getTableName(),
|
||||
QueryGenerator::getColumnNamesAndTypes(
|
||||
$this->dbi->quoteString($designerTable->getDatabaseName()),
|
||||
$this->dbi->quoteString($designerTable->getTableName()),
|
||||
),
|
||||
);
|
||||
/**
|
||||
* @var string $field
|
||||
* @var string $type
|
||||
*/
|
||||
foreach ($fieldsRs as ['Field' => $field, 'Type' => $type]) {
|
||||
foreach ($fieldsRs as ['COLUMN_NAME' => $field, 'COLUMN_TYPE' => $type]) {
|
||||
$tabColumn[$designerTable->getDbTableString()][] = new ColumnInfo($field, $type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Dbal;
|
||||
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Server;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -753,24 +752,17 @@ class DatabaseInterface
|
||||
* @param string $database name of database
|
||||
* @param string $table name of table to retrieve columns from
|
||||
* @param string $column name of column
|
||||
* @param T $full whether to return full info or only column names
|
||||
*
|
||||
* @psalm-return (T is true ? ColumnFull : Column)|null
|
||||
*
|
||||
* @template T of bool
|
||||
*/
|
||||
public function getColumn(
|
||||
string $database,
|
||||
string $table,
|
||||
string $column,
|
||||
bool $full = false,
|
||||
ConnectionType $connectionType = ConnectionType::User,
|
||||
): ColumnFull|Column|null {
|
||||
$sql = QueryGenerator::getColumnsSql(
|
||||
$database,
|
||||
$table,
|
||||
$this->quoteString($this->escapeMysqlWildcards($column)),
|
||||
$full,
|
||||
): Column|null {
|
||||
$sql = QueryGenerator::getColumns(
|
||||
$this->quoteString($database, $connectionType),
|
||||
$this->quoteString($table, $connectionType),
|
||||
$this->quoteString($column, $connectionType),
|
||||
);
|
||||
/** @var (string|null)[][] $fields */
|
||||
$fields = $this->fetchResult($sql, 'Field', null, $connectionType);
|
||||
@ -790,7 +782,7 @@ class DatabaseInterface
|
||||
*/
|
||||
$columns = $this->attachIndexInfoToColumns($database, $table, $fields);
|
||||
|
||||
$columns = $this->convertToColumns($columns, $full);
|
||||
$columns = $this->convertToColumns($columns);
|
||||
|
||||
return array_shift($columns);
|
||||
}
|
||||
@ -800,20 +792,18 @@ class DatabaseInterface
|
||||
*
|
||||
* @param string $database name of database
|
||||
* @param string $table name of table to retrieve columns from
|
||||
* @param T $full whether to return full info or only column names
|
||||
*
|
||||
* @return ColumnFull[]|Column[]
|
||||
* @psalm-return (T is true ? ColumnFull[] : Column[])
|
||||
*
|
||||
* @template T of bool
|
||||
* @return Column[]
|
||||
*/
|
||||
public function getColumns(
|
||||
string $database,
|
||||
string $table,
|
||||
bool $full = false,
|
||||
ConnectionType $connectionType = ConnectionType::User,
|
||||
): array {
|
||||
$sql = QueryGenerator::getColumnsSql($database, $table, null, $full);
|
||||
$sql = QueryGenerator::getColumns(
|
||||
$this->quoteString($database, $connectionType),
|
||||
$this->quoteString($table, $connectionType),
|
||||
);
|
||||
/** @var (string|null)[][] $fields */
|
||||
$fields = $this->fetchResult($sql, 'Field', null, $connectionType);
|
||||
|
||||
@ -832,7 +822,7 @@ class DatabaseInterface
|
||||
*/
|
||||
$columns = $this->attachIndexInfoToColumns($database, $table, $fields);
|
||||
|
||||
return $this->convertToColumns($columns, $full);
|
||||
return $this->convertToColumns($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -890,13 +880,13 @@ class DatabaseInterface
|
||||
* Comment: string
|
||||
* }[] $fields column array indexed by their names
|
||||
*
|
||||
* @return (ColumnFull|Column)[]
|
||||
* @return Column[]
|
||||
*/
|
||||
private function convertToColumns(array $fields, bool $full = false): array
|
||||
private function convertToColumns(array $fields): array
|
||||
{
|
||||
$columns = [];
|
||||
foreach ($fields as $field => $column) {
|
||||
$columns[$field] = $full ? new ColumnFull(
|
||||
$columns[$field] = new Column(
|
||||
$column['Field'],
|
||||
$column['Type'],
|
||||
$column['Collation'],
|
||||
@ -906,13 +896,6 @@ class DatabaseInterface
|
||||
$column['Extra'],
|
||||
$column['Privileges'],
|
||||
$column['Comment'],
|
||||
) : new Column(
|
||||
$column['Field'],
|
||||
$column['Type'],
|
||||
$column['Null'] === 'YES',
|
||||
$column['Key'],
|
||||
$column['Default'],
|
||||
$column['Extra'],
|
||||
);
|
||||
}
|
||||
|
||||
@ -932,7 +915,10 @@ class DatabaseInterface
|
||||
string $table,
|
||||
ConnectionType $connectionType = ConnectionType::User,
|
||||
): array {
|
||||
$sql = QueryGenerator::getColumnsSql($database, $table);
|
||||
$sql = QueryGenerator::getColumnNamesAndTypes(
|
||||
$this->quoteString($database, $connectionType),
|
||||
$this->quoteString($table, $connectionType),
|
||||
);
|
||||
|
||||
$result = $this->tryQuery($sql, $connectionType, cacheAffectedRows: false);
|
||||
|
||||
@ -941,7 +927,7 @@ class DatabaseInterface
|
||||
}
|
||||
|
||||
// We only need the 'Field' column which contains the table's column names
|
||||
return array_column($result->fetchAllAssoc(), 'Field');
|
||||
return array_column($result->fetchAllAssoc(), 'COLUMN_NAME');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1350,13 +1350,13 @@ class InsertEdit
|
||||
* @param string $db current db
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return list<ColumnFull>
|
||||
* @return list<Column>
|
||||
*/
|
||||
public function getTableColumns(string $db, string $table): array
|
||||
{
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
return array_values($this->dbi->getColumns($db, $table, true));
|
||||
return array_values($this->dbi->getColumns($db, $table));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1481,7 +1481,7 @@ class InsertEdit
|
||||
/**
|
||||
* Function to get html for each insert/edit column
|
||||
*
|
||||
* @param ColumnFull $tableColumn column
|
||||
* @param Column $tableColumn column
|
||||
* @param int $columnNumber column index in table_columns
|
||||
* @param string[] $commentsMap comments map
|
||||
* @param int $columnLength length of the current column taken from field metadata
|
||||
@ -1499,7 +1499,7 @@ class InsertEdit
|
||||
* @param string $whereClause the where clause
|
||||
*/
|
||||
private function getHtmlForInsertEditFormColumn(
|
||||
ColumnFull $tableColumn,
|
||||
Column $tableColumn,
|
||||
int $columnNumber,
|
||||
array $commentsMap,
|
||||
int $columnLength,
|
||||
@ -1793,7 +1793,7 @@ class InsertEdit
|
||||
* Function to get html for each insert/edit row
|
||||
*
|
||||
* @param array<string, bool|int|string> $urlParams url parameters
|
||||
* @param list<ColumnFull> $tableColumns table columns
|
||||
* @param list<Column> $tableColumns table columns
|
||||
* @param string[] $commentsMap comments map
|
||||
* @param FieldMetadata[] $fieldMetadata current result's field metadata
|
||||
* @param bool $insertMode whether insert mode
|
||||
|
||||
@ -71,7 +71,7 @@ class Normalization
|
||||
}
|
||||
|
||||
$this->dbi->selectDb($db);
|
||||
$columns = $this->dbi->getColumns($db, $table, true);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
$selectColHtml = '';
|
||||
foreach ($columns as $def) {
|
||||
$column = $def->field;
|
||||
|
||||
@ -1302,7 +1302,7 @@ class ExportSql extends ExportPlugin
|
||||
$createQuery .= Util::backquote($viewAlias) . '(' . "\n";
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$columns = $dbi->getColumns($db, $view, true);
|
||||
$columns = $dbi->getColumns($db, $view);
|
||||
|
||||
$firstCol = true;
|
||||
foreach ($columns as $column) {
|
||||
|
||||
@ -133,21 +133,42 @@ class Generator
|
||||
|
||||
/**
|
||||
* Returns SQL query for fetching columns for a table
|
||||
*
|
||||
* @param string $database name of database
|
||||
* @param string $table name of table to retrieve columns from
|
||||
* @param string|null $quotedColumn name of column, null to show all columns
|
||||
* @param bool $full whether to return full info or only column names
|
||||
*/
|
||||
public static function getColumnsSql(
|
||||
string $database,
|
||||
string $table,
|
||||
public static function getColumns(
|
||||
string $quotedDatabase,
|
||||
string $quotedTable,
|
||||
string|null $quotedColumn = null,
|
||||
bool $full = false,
|
||||
): string {
|
||||
return 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM '
|
||||
. Util::backquote($database) . '.' . Util::backquote($table)
|
||||
. ($quotedColumn !== null ? ' LIKE ' . $quotedColumn : '');
|
||||
return 'SELECT'
|
||||
. ' `COLUMN_NAME` AS `Field`,'
|
||||
. ' `COLUMN_TYPE` AS `Type`,'
|
||||
. ' `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`,'
|
||||
. ' `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`,'
|
||||
. ' `EXTRA` AS `Extra`,'
|
||||
. ' `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` ' . Util::getCollateForIS()
|
||||
. ' = ' . $quotedDatabase
|
||||
. ' AND `TABLE_NAME` ' . Util::getCollateForIS()
|
||||
. ' = ' . $quotedTable
|
||||
. ($quotedColumn !== null ? ' AND `COLUMN_NAME` = ' . $quotedColumn : '');
|
||||
}
|
||||
|
||||
public static function getColumnNamesAndTypes(
|
||||
string $quotedDatabase,
|
||||
string $quotedTable,
|
||||
): string {
|
||||
return 'SELECT'
|
||||
. ' `COLUMN_NAME`,'
|
||||
. ' `COLUMN_TYPE`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` ' . Util::getCollateForIS()
|
||||
. ' = ' . $quotedDatabase
|
||||
. ' AND `TABLE_NAME` ' . Util::getCollateForIS()
|
||||
. ' = ' . $quotedTable;
|
||||
}
|
||||
|
||||
public static function getInformationSchemaRoutinesRequest(
|
||||
|
||||
@ -133,7 +133,7 @@ class SqlQueryForm
|
||||
*
|
||||
* @param string $query query to display in the textarea
|
||||
*
|
||||
* @return array{string, string, ColumnFull[]}
|
||||
* @return array{string, string, Column[]}
|
||||
*/
|
||||
public function init(string $query): array
|
||||
{
|
||||
@ -167,7 +167,7 @@ class SqlQueryForm
|
||||
// Get the list and number of fields
|
||||
// we do a try_query here, because we could be in the query window,
|
||||
// trying to synchronize and the table has not yet been created
|
||||
$columnsList = $this->dbi->getColumns($db, Current::$table, true);
|
||||
$columnsList = $this->dbi->getColumns($db, Current::$table);
|
||||
|
||||
$scriptName = Url::getFromRoute($this->config->settings['DefaultTabTable']);
|
||||
$tmpTblLink = '<a href="' . $scriptName . Url::getCommon(['db' => $db, 'table' => $table], '&') . '">';
|
||||
|
||||
@ -178,7 +178,7 @@ class Tracker
|
||||
// Get data definition snapshot of table
|
||||
|
||||
$columns = [];
|
||||
foreach ($dbi->getColumns($dbName, $tableName, true) as $column) {
|
||||
foreach ($dbi->getColumns($dbName, $tableName) as $column) {
|
||||
$columns[] = [
|
||||
'Field' => $column->field,
|
||||
'Type' => $column->type,
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\ConfigStorage;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
@ -117,8 +117,8 @@ class RelationTest extends AbstractTestCase
|
||||
->getMock();
|
||||
|
||||
$getColumnsResult = [
|
||||
new ColumnFull('field1', 'int(11)', null, false, '', null, '', '', 'Comment1'),
|
||||
new ColumnFull('field2', 'text', null, false, '', null, '', '', 'Comment1'),
|
||||
new Column('field1', 'int(11)', null, false, '', null, '', '', 'Comment1'),
|
||||
new Column('field2', 'text', null, false, '', null, '', '', 'Comment1'),
|
||||
];
|
||||
$dbi->expects(self::any())->method('getColumns')
|
||||
->willReturn($getColumnsResult);
|
||||
|
||||
@ -55,7 +55,7 @@ class SqlControllerTest extends AbstractTestCase
|
||||
new UserPreferences($this->dbi, new Relation($this->dbi), new Template()),
|
||||
);
|
||||
$pageSettings->init('Sql');
|
||||
$fields = $this->dbi->getColumns('test_db', 'test_table', true);
|
||||
$fields = $this->dbi->getColumns('test_db', 'test_table');
|
||||
$template = new Template();
|
||||
|
||||
$expected = $pageSettings->getHTML();
|
||||
|
||||
@ -87,7 +87,7 @@ class StructureControllerTest extends AbstractTestCase
|
||||
new UserPreferences($this->dbi, new Relation($this->dbi), new Template()),
|
||||
);
|
||||
$pageSettings->init('TableStructure');
|
||||
$fields = $this->dbi->getColumns(Current::$database, Current::$table, true);
|
||||
$fields = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/')
|
||||
->withQueryParams(['route' => '/table/structure', 'db' => 'test_db', 'table' => 'test_table']);
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Database;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
@ -139,9 +139,9 @@ class CentralColumnsTest extends AbstractTestCase
|
||||
$this->dbi->expects(self::any())
|
||||
->method('getColumns')
|
||||
->willReturn([
|
||||
'id' => new ColumnFull('id', 'integer', null, false, '', null, '', '', ''),
|
||||
'col1' => new ColumnFull('col1', 'varchar(100)', null, true, '', null, '', '', ''),
|
||||
'col2' => new ColumnFull('col2', 'DATETIME', null, false, '', null, '', '', ''),
|
||||
'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
|
||||
'col1' => new Column('col1', 'varchar(100)', null, true, '', null, '', '', ''),
|
||||
'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
|
||||
]);
|
||||
$this->dbi->expects(self::any())
|
||||
->method('getColumnNames')
|
||||
|
||||
@ -38,8 +38,8 @@ class SearchTest extends AbstractTestCase
|
||||
->method('getColumns')
|
||||
->with('pma', 'table1')
|
||||
->willReturn([
|
||||
new Column('column1', '', false, '', null, ''),
|
||||
new Column('column2', '', false, '', null, ''),
|
||||
new Column('column1', '', null, false, '', null, '', '', ''),
|
||||
new Column('column2', '', null, false, '', null, '', '', ''),
|
||||
]);
|
||||
|
||||
$dbi->expects(self::any())
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Server;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -26,7 +25,7 @@ use function array_keys;
|
||||
|
||||
#[CoversClass(DatabaseInterface::class)]
|
||||
#[CoversClass(Column::class)]
|
||||
#[CoversClass(ColumnFull::class)]
|
||||
#[CoversClass(Column::class)]
|
||||
class DatabaseInterfaceTest extends AbstractTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
@ -865,7 +864,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
);
|
||||
$dbiDummy->addResult('SHOW INDEXES FROM `test_db`.`test_table`', []);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
$column = new Column('test_column', 'varchar(45)', false, '', null, '');
|
||||
$column = new Column('test_column', 'varchar(45)', null, false, '', null, '', '', '');
|
||||
self::assertEquals($column, $dbi->getColumn('test_db', 'test_table', 'test_column'));
|
||||
$dbiDummy->assertAllQueriesConsumed();
|
||||
}
|
||||
@ -883,7 +882,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
);
|
||||
$dbiDummy->addResult('SHOW INDEXES FROM `test_db`.`test_table`', []);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
$column = new ColumnFull(
|
||||
$column = new Column(
|
||||
'test_column',
|
||||
'varchar(45)',
|
||||
'utf8mb4_general_ci',
|
||||
@ -894,7 +893,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
'select,insert,update,references',
|
||||
'',
|
||||
);
|
||||
self::assertEquals($column, $dbi->getColumn('test_db', 'test_table', 'test_column', true));
|
||||
self::assertEquals($column, $dbi->getColumn('test_db', 'test_table', 'test_column'));
|
||||
$dbiDummy->assertAllQueriesConsumed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Core;
|
||||
@ -2262,8 +2262,8 @@ class InsertEditTest extends AbstractTestCase
|
||||
->with('db');
|
||||
|
||||
$columns = [
|
||||
new ColumnFull('b', 'd', null, false, '', null, '', '', ''),
|
||||
new ColumnFull('f', 'h', null, true, '', null, '', '', ''),
|
||||
new Column('b', 'd', null, false, '', null, '', '', ''),
|
||||
new Column('f', 'h', null, true, '', null, '', '', ''),
|
||||
];
|
||||
|
||||
$dbi->expects(self::once())
|
||||
@ -2285,8 +2285,8 @@ class InsertEditTest extends AbstractTestCase
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
new ColumnFull('b', 'd', null, false, '', null, '', '', ''),
|
||||
new ColumnFull('f', 'h', null, true, '', null, '', '', ''),
|
||||
new Column('b', 'd', null, false, '', null, '', '', ''),
|
||||
new Column('f', 'h', null, true, '', null, '', '', ''),
|
||||
],
|
||||
$result,
|
||||
);
|
||||
@ -2373,7 +2373,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('db', 'table', true)
|
||||
->willReturn([new ColumnFull('d', 'd', null, false, '', null, '', '', 'b')]);
|
||||
->willReturn([new Column('d', 'd', null, false, '', null, '', '', 'b')]);
|
||||
|
||||
$dbi->expects(self::any())
|
||||
->method('getTable')
|
||||
@ -2430,7 +2430,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
$_SESSION[' HMAC_secret '] = hash('sha1', 'test');
|
||||
InsertEdit::$pluginScripts = [];
|
||||
$foreigners = ['foreign_keys_data' => []];
|
||||
$tableColumn = new ColumnFull('col', 'varchar(20)', null, true, '', null, '', 'insert,update,select', '');
|
||||
$tableColumn = new Column('col', 'varchar(20)', null, true, '', null, '', 'insert,update,select', '');
|
||||
$repopulate = [md5('col') => 'val'];
|
||||
$columnMime = [
|
||||
'input_transformation' => 'Input/Image_JPEG_Upload.php',
|
||||
@ -2480,7 +2480,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
// Test w/o input_transformation
|
||||
$tableColumn = new ColumnFull('qwerty', 'datetime', null, true, '', null, '', 'insert,update,select', '');
|
||||
$tableColumn = new Column('qwerty', 'datetime', null, true, '', null, '', 'insert,update,select', '');
|
||||
$repopulate = [md5('qwerty') => '12-10-14'];
|
||||
$actual = $this->callFunction(
|
||||
$this->insertEdit,
|
||||
@ -2569,7 +2569,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
$config->settings['TextareaCols'] = 11;
|
||||
$foreigners = ['foreign_keys_data' => []];
|
||||
$tableColumns = [
|
||||
new ColumnFull('test', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
new Column('test', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
];
|
||||
|
||||
$actual = $this->insertEdit->getHtmlForInsertEditRow(
|
||||
@ -2612,8 +2612,8 @@ class InsertEditTest extends AbstractTestCase
|
||||
|
||||
// edit
|
||||
$tableColumns = [
|
||||
new ColumnFull('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
new ColumnFull('bar', 'longtext', null, true, '', null, '', 'select,insert,references', ''),
|
||||
new Column('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
new Column('bar', 'longtext', null, true, '', null, '', 'select,insert,references', ''),
|
||||
];
|
||||
|
||||
$fieldMetadata = [
|
||||
@ -2642,9 +2642,9 @@ class InsertEditTest extends AbstractTestCase
|
||||
|
||||
// insert
|
||||
$tableColumns = [
|
||||
new ColumnFull('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
new ColumnFull('bar', 'longtext', null, true, '', null, '', 'select,update,references', ''),
|
||||
new ColumnFull('point', 'point', null, false, '', null, '', 'select,update,references', ''),
|
||||
new Column('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
|
||||
new Column('bar', 'longtext', null, true, '', null, '', 'select,update,references', ''),
|
||||
new Column('point', 'point', null, false, '', null, '', 'select,update,references', ''),
|
||||
];
|
||||
$actual = $this->insertEdit->getHtmlForInsertEditRow(
|
||||
[],
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -70,9 +70,9 @@ class NormalizationTest extends AbstractTestCase
|
||||
$dbi->expects(self::any())
|
||||
->method('getColumns')
|
||||
->willReturn([
|
||||
'id' => new ColumnFull('id', 'integer', null, false, '', null, '', '', ''),
|
||||
'col1' => new ColumnFull('col1', 'varchar(100)', null, false, '', null, '', '', ''),
|
||||
'col2' => new ColumnFull('col2', 'DATETIME', null, false, '', null, '', '', ''),
|
||||
'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
|
||||
'col1' => new Column('col1', 'varchar(100)', null, false, '', null, '', '', ''),
|
||||
'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
|
||||
]);
|
||||
$dbi->expects(self::any())
|
||||
->method('getColumnNames')
|
||||
|
||||
@ -348,7 +348,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
->with('database', 'view')
|
||||
->willReturn($keys);
|
||||
|
||||
$column = new Column('column', '', false, '', null, '');
|
||||
$column = new Column('column', '', null, false, '', null, '', '', '');
|
||||
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
@ -402,7 +402,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
->with('database', '')
|
||||
->willReturn($keys);
|
||||
|
||||
$column = new Column('fieldname', '', false, '', null, '');
|
||||
$column = new Column('fieldname', '', null, false, '', null, '', '', '');
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('database', '')
|
||||
@ -477,7 +477,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
->with('database', '')
|
||||
->willReturn($keys);
|
||||
|
||||
$column = new Column('fieldname', '', false, '', null, '');
|
||||
$column = new Column('fieldname', '', null, false, '', null, '', '', '');
|
||||
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
@ -526,7 +526,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
->with('database', '')
|
||||
->willReturn($keys);
|
||||
|
||||
$column = new Column('fieldname', '', false, '', null, '');
|
||||
$column = new Column('fieldname', '', null, false, '', null, '', '', '');
|
||||
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
@ -667,7 +667,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
{
|
||||
$method = new ReflectionMethod(ExportHtmlword::class, 'formatOneColumnDefinition');
|
||||
|
||||
$column = new Column('field', 'set(abc)enum123', true, 'PRI', null, '');
|
||||
$column = new Column('field', 'set(abc)enum123', null, true, 'PRI', null, '', '', '');
|
||||
|
||||
$uniqueKeys = ['field'];
|
||||
|
||||
@ -678,7 +678,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$method->invoke($this->object, $column, $uniqueKeys),
|
||||
);
|
||||
|
||||
$column = new Column('fields', '', false, 'COMP', 'def', '');
|
||||
$column = new Column('fields', '', null, false, 'COMP', 'def', '', '', '');
|
||||
|
||||
$uniqueKeys = ['field'];
|
||||
|
||||
|
||||
@ -585,8 +585,8 @@ class ExportLatexTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
$columns = [
|
||||
new Column('name1', 'set(abc)enum123', true, 'PRI', null, ''),
|
||||
new Column('fields', '', false, 'COMP', 'def', ''),
|
||||
new Column('name1', 'set(abc)enum123', null, true, 'PRI', null, '', '', ''),
|
||||
new Column('fields', '', null, false, 'COMP', 'def', '', '', ''),
|
||||
];
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
|
||||
@ -229,8 +229,8 @@ class ExportMediawikiTest extends AbstractTestCase
|
||||
->getMock();
|
||||
|
||||
$columns = [
|
||||
new Column('name1', 'set(abc)enum123', true, 'PRI', '', ''),
|
||||
new Column('fields', '', false, 'COMP', 'def', 'ext'),
|
||||
new Column('name1', 'set(abc)enum123', null, true, 'PRI', '', '', '', ''),
|
||||
new Column('fields', '', null, false, 'COMP', 'def', 'ext', '', ''),
|
||||
];
|
||||
|
||||
$dbi->expects(self::once())
|
||||
|
||||
@ -594,7 +594,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
['fieldname' => ['values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<']],
|
||||
);
|
||||
|
||||
$column = new Column('fieldname', '', false, '', null, '');
|
||||
$column = new Column('fieldname', '', null, false, '', null, '', '', '');
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('database', '')
|
||||
@ -675,7 +675,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
['field' => ['values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<']],
|
||||
);
|
||||
|
||||
$column = new Column('fieldname', '', false, '', null, '');
|
||||
$column = new Column('fieldname', '', null, false, '', null, '', '', '');
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('database', '')
|
||||
@ -868,7 +868,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
{
|
||||
$method = new ReflectionMethod(ExportOdt::class, 'formatOneColumnDefinition');
|
||||
|
||||
$column = new Column('field', 'set(abc)enum123', true, 'PRI', null, '');
|
||||
$column = new Column('field', 'set(abc)enum123', null, true, 'PRI', null, '', '', '');
|
||||
|
||||
$colAlias = 'alias';
|
||||
|
||||
@ -882,7 +882,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$method->invoke($this->object, $column, $colAlias),
|
||||
);
|
||||
|
||||
$column = new Column('fields', '', false, 'COMP', 'def', '');
|
||||
$column = new Column('fields', '', null, false, 'COMP', 'def', '', '', '');
|
||||
|
||||
self::assertSame(
|
||||
'<table:table-row><table:table-cell office:value-type="string">' .
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
@ -684,7 +683,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->willReturn([
|
||||
new ColumnFull(
|
||||
new Column(
|
||||
'fname',
|
||||
'char',
|
||||
'utf-8',
|
||||
@ -725,7 +724,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->willReturn([
|
||||
new ColumnFull(
|
||||
new Column(
|
||||
'fname',
|
||||
'char',
|
||||
'utf-8',
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
@ -289,8 +288,8 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
->method('fetchValue')
|
||||
->willReturn('SELECT a FROM b');
|
||||
|
||||
$column = new Column('fname', '', false, '', null, '');
|
||||
$columnFull = new ColumnFull('fname', '', null, false, '', null, '', '', 'comm');
|
||||
$column = new Column('fname', '', null, false, '', null, '', '', '');
|
||||
$columnFull = new Column('fname', '', null, false, '', null, '', '', 'comm');
|
||||
|
||||
$dbi->expects(self::exactly(2))
|
||||
->method('getColumns')
|
||||
@ -421,7 +420,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
|
||||
public function testFormatOneColumnDefinition(): void
|
||||
{
|
||||
$cols = new Column('field', 'set(abc)enum123', true, 'PRI', null, '');
|
||||
$cols = new Column('field', 'set(abc)enum123', null, true, 'PRI', null, '', '', '');
|
||||
|
||||
$uniqueKeys = ['field'];
|
||||
|
||||
@ -430,7 +429,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->formatOneColumnDefinition($cols, $uniqueKeys),
|
||||
);
|
||||
|
||||
$cols = new Column('fields', '', false, 'COMP', 'def', '');
|
||||
$cols = new Column('fields', '', null, false, 'COMP', 'def', '', '', '');
|
||||
|
||||
$uniqueKeys = ['field'];
|
||||
|
||||
|
||||
@ -15,14 +15,14 @@ class GeneratorTest extends AbstractTestCase
|
||||
{
|
||||
self::assertSame(
|
||||
'SHOW COLUMNS FROM `mydb`.`mytable`',
|
||||
Generator::getColumnsSql(
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
),
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW COLUMNS FROM `mydb`.`mytable` LIKE \'_idcolumn\'',
|
||||
Generator::getColumnsSql(
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'_idcolumn'",
|
||||
@ -30,20 +30,18 @@ class GeneratorTest extends AbstractTestCase
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW FULL COLUMNS FROM `mydb`.`mytable`',
|
||||
Generator::getColumnsSql(
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
null,
|
||||
true,
|
||||
),
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW FULL COLUMNS FROM `mydb`.`mytable` LIKE \'_idcolumn\'',
|
||||
Generator::getColumnsSql(
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'_idcolumn'",
|
||||
true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Tracking;
|
||||
|
||||
use PhpMyAdmin\ColumnFull;
|
||||
use PhpMyAdmin\Column;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
@ -168,8 +168,8 @@ class TrackerTest extends AbstractTestCase
|
||||
*/
|
||||
|
||||
$getColumnsResult = [
|
||||
new ColumnFull('field1', 'int(11)', null, false, 'PRI', null, '', '', ''),
|
||||
new ColumnFull('field2', 'text', null, false, '', null, '', '', ''),
|
||||
new Column('field1', 'int(11)', null, false, 'PRI', null, '', '', ''),
|
||||
new Column('field2', 'text', null, false, '', null, '', '', ''),
|
||||
];
|
||||
$dbi->expects(self::once())->method('getColumns')
|
||||
->with('pma_test', 'pma_tbl')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user