Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve deprecated methods #253

Merged
merged 5 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Enh #251: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov)
- Bug #238: Fix execution `Query` without table(s) to select from (@Tigrov)
- Bug #254: Fix, table sequence name should be null if sequence name not found (@Tigrov)
- Enh #253: Resolve deprecated methods (@Tigrov)

## 1.2.0 November 12, 2023

Expand Down
14 changes: 9 additions & 5 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Yiisoft\Db\Schema\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_change_key_case;
use function array_map;
use function array_merge;
use function array_reverse;
use function implode;
Expand Down Expand Up @@ -208,7 +210,7 @@ protected function findTableNames(string $schema = ''): array
/** @psalm-var string[][] $rows */
foreach ($rows as $row) {
/** @psalm-var string[] $row */
$row = $this->normalizeRowKeyCase($row, false);
$row = array_change_key_case($row);
$names[] = $row['table_name'];
}

Expand Down Expand Up @@ -287,7 +289,7 @@ protected function loadTableIndexes(string $tableName): array
])->queryAll();

/** @psalm-var array[] $indexes */
$indexes = $this->normalizeRowKeyCase($indexes, true);
$indexes = array_map('array_change_key_case', $indexes);
$indexes = DbArrayHelper::index($indexes, null, ['name']);

$result = [];
Expand Down Expand Up @@ -406,7 +408,7 @@ protected function findColumns(TableSchemaInterface $table): bool
/** @psalm-var string[][] $columns */
foreach ($columns as $column) {
/** @psalm-var ColumnInfoArray $column */
$column = $this->normalizeRowKeyCase($column, false);
$column = array_change_key_case($column);

$c = $this->createColumnSchema($column);

Expand Down Expand Up @@ -554,7 +556,7 @@ protected function findConstraints(TableSchemaInterface $table): void

foreach ($rows as $row) {
/** @psalm-var string[] $row */
$row = $this->normalizeRowKeyCase($row, false);
$row = array_change_key_case($row);

if ($row['constraint_type'] === 'P') {
$table->getColumns()[$row['column_name']]->primaryKey(true);
Expand Down Expand Up @@ -715,7 +717,7 @@ private function loadTableConstraints(string $tableName, string $returnType): mi
])->queryAll();

/** @psalm-var array[] $constraints */
$constraints = $this->normalizeRowKeyCase($constraints, true);
$constraints = array_map('array_change_key_case', $constraints);
$constraints = DbArrayHelper::index($constraints, null, ['type', 'name']);

$result = [
Expand Down Expand Up @@ -805,6 +807,8 @@ protected function findViewNames(string $schema = ''): array
* @param string $name The table name.
*
* @return array The cache key.
*
* @psalm-suppress DeprecatedMethod
*/
protected function getCacheKey(string $name): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ public function testNotConnectionPDO(): void
$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Only PDO connections are supported.');

$schema->refreshTableSchema('customer');
$schema->refresh();
}
}
Loading