Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed May 5, 2024
1 parent 2f67fd4 commit 02df181
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 100 deletions.
96 changes: 0 additions & 96 deletions src/ColumnSchema.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected function findColumns(TableSchemaInterface $table): bool
}

$column = $this->loadColumnSchema($info);
$table->column($column->getName(), $column);
$table->column($info['field'], $column);

if ($column->isPrimaryKey()) {
$table->primaryKey($column->getName());

Check failure on line 229 in src/Schema.php

View workflow job for this annotation

GitHub Actions / PHP 8.0

PossiblyNullArgument

src/Schema.php:229:36: PossiblyNullArgument: Argument 1 of Yiisoft\Db\Schema\TableSchemaInterface::primaryKey cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 229 in src/Schema.php

View workflow job for this annotation

GitHub Actions / PHP 8.0

PossiblyNullArgument

src/Schema.php:229:36: PossiblyNullArgument: Argument 1 of Yiisoft\Db\Schema\TableSchemaInterface::primaryKey cannot be null, possibly null value provided (see https://psalm.dev/078)
Expand Down Expand Up @@ -488,7 +488,6 @@ private function loadColumnSchema(array $info): ColumnSchemaInterface
}

$column->extra($extra);
$column->phpType($this->getColumnPhpType($type));
$column->defaultValue($this->normalizeDefaultValue($info['default'], $column));

if (str_starts_with($extra, 'DEFAULT_GENERATED')) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ColumnSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testPhpTypeCast(): void
$jsonColPhpType = $tableSchema->getColumn('json_col')?->phpTypecast($query['json_col']);

$this->assertSame(1, $intColPhpType);
$this->assertSame(1234567890, $bigUnsignedColPhpType);
$this->assertSame('1234567890', $bigUnsignedColPhpType);
$this->assertSame(str_repeat('x', 100), $charColPhpType);
$this->assertNull($charCol3PhpType);
$this->assertSame(1.234, $floatColPhpType);
Expand Down
2 changes: 1 addition & 1 deletion tests/Provider/SchemaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function columns(): array
'bigunsigned_col' => [
'type' => 'bigint',
'dbType' => 'bigint(20) unsigned',
'phpType' => 'integer',
'phpType' => 'string',
'primaryKey' => false,
'allowNull' => true,
'autoIncrement' => false,
Expand Down

0 comments on commit 02df181

Please sign in to comment.