Skip to content

Commit

Permalink
Merge branch 'master' into fix-update-with-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Mar 13, 2024
2 parents b7db8c6 + 9d30cf9 commit 573f6f7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
- ubuntu-latest

php:
- 8.0
- 8.1

steps:
Expand Down Expand Up @@ -71,6 +70,6 @@ jobs:

- name: Run infection.
run: |
vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Enh #282: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)
- Enh #283: Remove unnecessary check for array type in `Schema::loadTableIndexes()` (@Tigrov)
- Enh #288: Minor refactoring of `DDLQueryBuilder` and `Schema` (@Tigrov)
- Enh #287: Resolve deprecated methods (@Tigrov)

## 1.1.0 November 12, 2023

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ext-json": "*",
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^10.0",
"rector/rector": "^0.19",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.20",
Expand Down
17 changes: 13 additions & 4 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_column;
use function array_map;
use function array_merge;
use function count;
use function explode;
Expand Down Expand Up @@ -201,7 +202,7 @@ protected function loadTableForeignKeys(string $tableName): array

$foreignKeysList = $this->getPragmaForeignKeyList($tableName);
/** @psalm-var ForeignKeyInfo[] $foreignKeysList */
$foreignKeysList = $this->normalizeRowKeyCase($foreignKeysList, true);
$foreignKeysList = array_map('array_change_key_case', $foreignKeysList);
$foreignKeysList = DbArrayHelper::index($foreignKeysList, null, ['table']);
DbArrayHelper::multisort($foreignKeysList, 'seq');

Expand Down Expand Up @@ -553,7 +554,7 @@ private function loadTableColumnsInfo(string $tableName): array
{
$tableColumns = $this->getPragmaTableInfo($tableName);
/** @psalm-var ColumnInfo[] $tableColumns */
$tableColumns = $this->normalizeRowKeyCase($tableColumns, true);
$tableColumns = array_map('array_change_key_case', $tableColumns);

/** @psalm-var ColumnInfo[] */
return DbArrayHelper::index($tableColumns, 'cid');
Expand All @@ -575,7 +576,7 @@ private function loadTableConstraints(string $tableName, string $returnType): Co
{
$indexList = $this->getPragmaIndexList($tableName);
/** @psalm-var IndexListInfo[] $indexes */
$indexes = $this->normalizeRowKeyCase($indexList, true);
$indexes = array_map('array_change_key_case', $indexList);
$result = [
self::PRIMARY_KEY => null,
self::INDEXES => [],
Expand Down Expand Up @@ -642,9 +643,12 @@ private function createColumnSchema(string $name): ColumnSchemaInterface
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @psalm-return ForeignKeyInfo[]
*/
private function getPragmaForeignKeyList(string $tableName): array
{
/** @psalm-var ForeignKeyInfo[] */
return $this->db->createCommand(
'PRAGMA FOREIGN_KEY_LIST(' . $this->db->getQuoter()->quoteSimpleTableName($tableName) . ')'
)->queryAll();
Expand All @@ -662,7 +666,7 @@ private function getPragmaIndexInfo(string $name): array
$column = $this->db
->createCommand('PRAGMA INDEX_INFO(' . (string) $this->db->getQuoter()->quoteValue($name) . ')')
->queryAll();
$column = $this->normalizeRowKeyCase($column, true);
$column = array_map('array_change_key_case', $column);
DbArrayHelper::multisort($column, 'seqno');

/** @psalm-var IndexInfo[] $column */
Expand All @@ -673,9 +677,12 @@ private function getPragmaIndexInfo(string $name): array
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @psalm-return IndexListInfo[]
*/
private function getPragmaIndexList(string $tableName): array
{
/** @psalm-var IndexListInfo[] */
return $this->db
->createCommand('PRAGMA INDEX_LIST(' . (string) $this->db->getQuoter()->quoteValue($tableName) . ')')
->queryAll();
Expand Down Expand Up @@ -723,6 +730,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
4 changes: 2 additions & 2 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ public function testWorkWithPrimaryKeyConstraint(): void
public function testNotConnectionPDO(): void
{
$db = $this->createMock(ConnectionInterface::class);
$schema = new Schema($db, DbHelper::getSchemaCache(), 'system');
$schema = new Schema($db, DbHelper::getSchemaCache());

$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Only PDO connections are supported.');

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

0 comments on commit 573f6f7

Please sign in to comment.