From b4d74ab67f6d40b1437db986e3a1b2073b5151f6 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 8 Nov 2024 19:45:00 +0700 Subject: [PATCH 01/12] Refactor `normalizeDefaultValue()` --- src/Column/ColumnFactory.php | 61 +++++++++++++++++ src/Column/SequenceColumnSchemaTrait.php | 2 +- src/Schema.php | 84 ++++-------------------- tests/ColumnFactoryTest.php | 16 +++-- tests/Provider/ColumnFactoryProvider.php | 14 ++++ 5 files changed, 102 insertions(+), 75 deletions(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index c73d4370..8c1c690e 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -6,9 +6,17 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Constraint\ForeignKeyConstraint; +use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Schema\Column\AbstractColumnFactory; use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use function hex2bin; +use function is_numeric; +use function preg_replace; +use function str_replace; +use function str_starts_with; +use function substr; + use const PHP_INT_SIZE; /** @@ -114,6 +122,26 @@ final class ColumnFactory extends AbstractColumnFactory 'jsonb' => ColumnType::JSON, ]; + public function fromType(string $type, array $info = []): ColumnSchemaInterface + { + $column = parent::fromType($type, $info); + + if ($column instanceof StructuredColumnSchema) { + /** @psalm-var array|null $defaultValue */ + $defaultValue = $column->getDefaultValue(); + + if (is_array($defaultValue)) { + foreach ($column->getColumns() as $structuredColumnName => $structuredColumn) { + if (isset($defaultValue[$structuredColumnName])) { + $structuredColumn->defaultValue($defaultValue[$structuredColumnName]); + } + } + } + } + + return $column; + } + protected function getColumnClass(string $type, array $info = []): string { return match ($type) { @@ -131,4 +159,37 @@ protected function getColumnClass(string $type, array $info = []): string default => parent::getColumnClass($type, $info), }; } + + protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSchemaInterface $column): mixed + { + $value = preg_replace('/::[^:]+$/', '$1', $defaultValue); + + if ($value[0] === '(' && $value[-1] === ')') { + $value = substr($value, 1, -1); + } + + if (is_numeric($value)) { + return $column->phpTypecast($value); + } + + if ($value[0] === "'" && $value[-1] === "'") { + $value = substr($value, 1, -1); + + if (str_starts_with($value, '\\x')) { + return hex2bin(substr($value, 2)); + } + + return $column->phpTypecast(str_replace("''", "'", $value)); + } + + if (str_starts_with($value, "B'") && $value[-1] === "'") { + return $column->phpTypecast(substr($value, 2, -1)); + } + + return match ($value) { + 'true' => true, + 'false' => false, + default => new Expression($defaultValue), + }; + } } diff --git a/src/Column/SequenceColumnSchemaTrait.php b/src/Column/SequenceColumnSchemaTrait.php index 3beab37b..1a9795fd 100644 --- a/src/Column/SequenceColumnSchemaTrait.php +++ b/src/Column/SequenceColumnSchemaTrait.php @@ -9,7 +9,7 @@ trait SequenceColumnSchemaTrait /** * @var string|null Name of an associated sequence if column is auto incremental. */ - private string|null $sequenceName = null; + protected string|null $sequenceName = null; public function getSequenceName(): string|null { diff --git a/src/Schema.php b/src/Schema.php index dd31aee1..12233df2 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -760,92 +760,36 @@ private function loadColumnSchema(array $info): ColumnSchemaInterface $columnInfo['columns'] = $structured->getColumns(); } - $column = $columnFactory->fromType(ColumnType::STRUCTURED, $columnInfo); - } else { - $column = $columnFactory->fromDbType($dbType, $columnInfo); + $columnInfo['type'] = ColumnType::STRUCTURED; } $dimension = (int) $info['dimension']; if ($dimension > 0) { - $columnInfo['column'] = $column; + $columnInfo['column'] = $columnFactory->fromDbType($dbType, $columnInfo); $columnInfo['dimension'] = $dimension; + $columnInfo['defaultValueRaw'] = $info['column_default']; - $column = $columnFactory->fromType(ColumnType::ARRAY, $columnInfo); + return $columnFactory->fromType(ColumnType::ARRAY, $columnInfo); } + $defaultValue = $info['column_default']; + /** * pg_get_serial_sequence() doesn't track DEFAULT value change. * GENERATED BY IDENTITY columns always have a null default value. */ - $defaultValue = $info['column_default']; - - if ($column instanceof SequenceColumnSchemaInterface) { - if ( - $defaultValue !== null - && preg_match("/^nextval\('([^']+)/", $defaultValue, $matches) === 1 - ) { - $column->sequenceName($matches[1]); - } elseif ($info['sequence_name'] !== null) { - $column->sequenceName($this->resolveTableName($info['sequence_name'])->getFullName()); - } - } - - $column->defaultValue($this->normalizeDefaultValue($defaultValue, $column)); - - if ($column instanceof StructuredColumnSchema) { - /** @psalm-var array|null $defaultValue */ - $defaultValue = $column->getDefaultValue(); - - if (is_array($defaultValue)) { - foreach ($column->getColumns() as $structuredColumnName => $structuredColumn) { - if (isset($defaultValue[$structuredColumnName])) { - $structuredColumn->defaultValue($defaultValue[$structuredColumnName]); - } - } - } - } - - return $column; - } - - /** - * Converts column's default value according to {@see ColumnSchema::phpType} after retrieval from the database. - * - * @param string|null $defaultValue The default value retrieved from the database. - * @param ColumnSchemaInterface $column The column schema object. - * - * @return mixed The normalized default value. - */ - private function normalizeDefaultValue(string|null $defaultValue, ColumnSchemaInterface $column): mixed - { - if ( - $defaultValue === null - || $column->isPrimaryKey() - || str_starts_with($defaultValue, 'NULL::') - ) { - return null; + if ($defaultValue !== null && preg_match("/^nextval\('([^']+)/", $defaultValue, $matches) === 1) { + $defaultValue = null; + $columnInfo['sequenceName'] = $matches[1]; + } elseif ($info['sequence_name'] !== null) { + $columnInfo['sequenceName'] = $this->resolveTableName($info['sequence_name'])->getFullName(); } - if ($column->getType() === ColumnType::BOOLEAN && in_array($defaultValue, ['true', 'false'], true)) { - return $defaultValue === 'true'; - } - - if ( - in_array($column->getType(), [ColumnType::TIMESTAMP, ColumnType::DATE, ColumnType::TIME], true) - && in_array(strtoupper($defaultValue), ['NOW()', 'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'CURRENT_TIME'], true) - ) { - return new Expression($defaultValue); - } - - $value = preg_replace("/^B?['(](.*?)[)'](?:::[^:]+)?$/s", '$1', $defaultValue); - $value = str_replace("''", "'", $value); - - if ($column->getType() === ColumnType::BINARY && str_starts_with($value, '\\x')) { - return hex2bin(substr($value, 2)); - } + $columnInfo['defaultValueRaw'] = $defaultValue; - return $column->phpTypecast($value); + /** @psalm-suppress InvalidArgument */ + return $columnFactory->fromDbType($dbType, $columnInfo); } /** diff --git a/tests/ColumnFactoryTest.php b/tests/ColumnFactoryTest.php index 10d0ee82..ec52392a 100644 --- a/tests/ColumnFactoryTest.php +++ b/tests/ColumnFactoryTest.php @@ -4,8 +4,10 @@ namespace Yiisoft\Db\Pgsql\Tests; +use PHPUnit\Framework\Attributes\DataProviderExternal; use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Pgsql\Column\ArrayColumnSchema; +use Yiisoft\Db\Pgsql\Tests\Provider\ColumnFactoryProvider; use Yiisoft\Db\Pgsql\Tests\Support\TestTrait; use Yiisoft\Db\Tests\AbstractColumnFactoryTest; @@ -16,7 +18,7 @@ final class ColumnFactoryTest extends AbstractColumnFactoryTest { use TestTrait; - /** @dataProvider \Yiisoft\Db\Pgsql\Tests\Provider\ColumnFactoryProvider::dbTypes */ + #[DataProviderExternal(ColumnFactoryProvider::class, 'dbTypes')] public function testFromDbType(string $dbType, string $expectedType, string $expectedInstanceOf): void { parent::testFromDbType($dbType, $expectedType, $expectedInstanceOf); @@ -35,7 +37,7 @@ public function testFromDbType(string $dbType, string $expectedType, string $exp $db->close(); } - /** @dataProvider \Yiisoft\Db\Pgsql\Tests\Provider\ColumnFactoryProvider::definitions */ + #[DataProviderExternal(ColumnFactoryProvider::class, 'definitions')] public function testFromDefinition( string $definition, string $expectedType, @@ -45,7 +47,7 @@ public function testFromDefinition( parent::testFromDefinition($definition, $expectedType, $expectedInstanceOf, $expectedMethodResults); } - /** @dataProvider \Yiisoft\Db\Pgsql\Tests\Provider\ColumnFactoryProvider::pseudoTypes */ + #[DataProviderExternal(ColumnFactoryProvider::class, 'pseudoTypes')] public function testFromPseudoType( string $pseudoType, string $expectedType, @@ -55,7 +57,7 @@ public function testFromPseudoType( parent::testFromPseudoType($pseudoType, $expectedType, $expectedInstanceOf, $expectedMethodResults); } - /** @dataProvider \Yiisoft\Db\Pgsql\Tests\Provider\ColumnFactoryProvider::types */ + #[DataProviderExternal(ColumnFactoryProvider::class, 'types')] public function testFromType(string $type, string $expectedType, string $expectedInstanceOf): void { parent::testFromType($type, $expectedType, $expectedInstanceOf); @@ -72,4 +74,10 @@ public function testFromType(string $type, string $expectedType, string $expecte $db->close(); } + + #[DataProviderExternal(ColumnFactoryProvider::class, 'defaultValueRaw')] + public function testFromTypeDefaultValueRaw(string $type, string|null $defaultValueRaw, mixed $expected): void + { + parent::testFromTypeDefaultValueRaw($type, $defaultValueRaw, $expected); + } } diff --git a/tests/Provider/ColumnFactoryProvider.php b/tests/Provider/ColumnFactoryProvider.php index 0e7dfb77..178fcd12 100644 --- a/tests/Provider/ColumnFactoryProvider.php +++ b/tests/Provider/ColumnFactoryProvider.php @@ -100,4 +100,18 @@ public static function pseudoTypes(): array return $result; } + + public static function defaultValueRaw(): array + { + $defaultValueRaw = parent::defaultValueRaw(); + + $defaultValueRaw[] = [ColumnType::TEXT, 'NULL::"text"', null]; + $defaultValueRaw[] = [ColumnType::TEXT, '(NULL)::"text"', null]; + $defaultValueRaw[] = [ColumnType::TEXT, "'str''ing'::\"text\"", "str'ing"]; + $defaultValueRaw[] = [ColumnType::INTEGER, '(-1)::"int"', -1]; + $defaultValueRaw[] = [ColumnType::BIT, "B'1011'::\"bit\"", 0b1011]; + $defaultValueRaw[] = [ColumnType::BINARY, "'\\x737472696e67'::bytea", 'string']; + + return $defaultValueRaw; + } } From e84d5ad653f95ee782fed01cc948ce4578a6bbe1 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 8 Nov 2024 12:45:20 +0000 Subject: [PATCH 02/12] Apply fixes from StyleCI --- src/Schema.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Schema.php b/src/Schema.php index 12233df2..ad7a269e 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -16,14 +16,12 @@ use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\Exception\InvalidConfigException; use Yiisoft\Db\Exception\NotSupportedException; -use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Helper\DbArrayHelper; use Yiisoft\Db\Pgsql\Column\ColumnFactory; use Yiisoft\Db\Pgsql\Column\SequenceColumnSchemaInterface; use Yiisoft\Db\Schema\Builder\ColumnInterface; use Yiisoft\Db\Schema\Column\ColumnFactoryInterface; use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; -use Yiisoft\Db\Schema\Column\StructuredColumnSchema; use Yiisoft\Db\Schema\TableSchemaInterface; use function array_change_key_case; @@ -34,7 +32,6 @@ use function in_array; use function is_string; use function preg_match; -use function preg_replace; use function str_replace; use function str_starts_with; use function substr; From 2fe0944a705276f2b542450b56b8fb46dc1a3293 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 8 Nov 2024 21:01:45 +0700 Subject: [PATCH 03/12] Improve --- src/Column/ColumnFactory.php | 2 +- tests/Provider/ColumnFactoryProvider.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 8c1c690e..1a8e5207 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -175,7 +175,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche if ($value[0] === "'" && $value[-1] === "'") { $value = substr($value, 1, -1); - if (str_starts_with($value, '\\x')) { + if ($column->getType() === ColumnType::BINARY && str_starts_with($value, '\\x')) { return hex2bin(substr($value, 2)); } diff --git a/tests/Provider/ColumnFactoryProvider.php b/tests/Provider/ColumnFactoryProvider.php index 178fcd12..50407eda 100644 --- a/tests/Provider/ColumnFactoryProvider.php +++ b/tests/Provider/ColumnFactoryProvider.php @@ -110,6 +110,7 @@ public static function defaultValueRaw(): array $defaultValueRaw[] = [ColumnType::TEXT, "'str''ing'::\"text\"", "str'ing"]; $defaultValueRaw[] = [ColumnType::INTEGER, '(-1)::"int"', -1]; $defaultValueRaw[] = [ColumnType::BIT, "B'1011'::\"bit\"", 0b1011]; + $defaultValueRaw[] = [ColumnType::STRING, "'\\x737472696e67'", '\\x737472696e67']; $defaultValueRaw[] = [ColumnType::BINARY, "'\\x737472696e67'::bytea", 'string']; return $defaultValueRaw; From fb6ea70e85c2d6bd23774ede44bbb4dde2f70c2a Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 09:46:55 +0700 Subject: [PATCH 04/12] Improve --- src/Column/ColumnFactory.php | 30 ++++++------------------ tests/Provider/ColumnFactoryProvider.php | 3 +++ 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 1a8e5207..40f56f7b 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -162,34 +162,18 @@ protected function getColumnClass(string $type, array $info = []): string protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSchemaInterface $column): mixed { - $value = preg_replace('/::[^:]+$/', '$1', $defaultValue); + $value = preg_replace("/::[^:']+$/", '$1', $defaultValue); - if ($value[0] === '(' && $value[-1] === ')') { - $value = substr($value, 1, -1); - } - - if (is_numeric($value)) { - return $column->phpTypecast($value); + if (str_starts_with($value, "B'") && $value[-1] === "'") { + return $column->phpTypecast(substr($value, 2, -1)); } - if ($value[0] === "'" && $value[-1] === "'") { - $value = substr($value, 1, -1); - - if ($column->getType() === ColumnType::BINARY && str_starts_with($value, '\\x')) { - return hex2bin(substr($value, 2)); - } + $value = parent::normalizeNotNullDefaultValue($value, $column); - return $column->phpTypecast(str_replace("''", "'", $value)); + if ($value instanceof Expression) { + return new Expression($defaultValue); } - if (str_starts_with($value, "B'") && $value[-1] === "'") { - return $column->phpTypecast(substr($value, 2, -1)); - } - - return match ($value) { - 'true' => true, - 'false' => false, - default => new Expression($defaultValue), - }; + return $value; } } diff --git a/tests/Provider/ColumnFactoryProvider.php b/tests/Provider/ColumnFactoryProvider.php index 50407eda..0c315f7c 100644 --- a/tests/Provider/ColumnFactoryProvider.php +++ b/tests/Provider/ColumnFactoryProvider.php @@ -5,6 +5,7 @@ namespace Yiisoft\Db\Pgsql\Tests\Provider; use Yiisoft\Db\Constant\ColumnType; +use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Pgsql\Column\BinaryColumnSchema; use Yiisoft\Db\Pgsql\Column\BitColumnSchema; use Yiisoft\Db\Pgsql\Column\BooleanColumnSchema; @@ -108,10 +109,12 @@ public static function defaultValueRaw(): array $defaultValueRaw[] = [ColumnType::TEXT, 'NULL::"text"', null]; $defaultValueRaw[] = [ColumnType::TEXT, '(NULL)::"text"', null]; $defaultValueRaw[] = [ColumnType::TEXT, "'str''ing'::\"text\"", "str'ing"]; + $defaultValueRaw[] = [ColumnType::TEXT, "'str::ing'::\"text\"", "str::ing"]; $defaultValueRaw[] = [ColumnType::INTEGER, '(-1)::"int"', -1]; $defaultValueRaw[] = [ColumnType::BIT, "B'1011'::\"bit\"", 0b1011]; $defaultValueRaw[] = [ColumnType::STRING, "'\\x737472696e67'", '\\x737472696e67']; $defaultValueRaw[] = [ColumnType::BINARY, "'\\x737472696e67'::bytea", 'string']; + $defaultValueRaw[] = [ColumnType::BINARY, '(1 + 2)::int', new Expression('(1 + 2)::int')]; return $defaultValueRaw; } From a453a199594f09114a7faf5aa83ab0a3dfe01a79 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 12 Nov 2024 02:47:11 +0000 Subject: [PATCH 05/12] Apply fixes from StyleCI --- src/Column/ColumnFactory.php | 3 --- tests/Provider/ColumnFactoryProvider.php | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 40f56f7b..f03b4f62 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -10,10 +10,7 @@ use Yiisoft\Db\Schema\Column\AbstractColumnFactory; use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; -use function hex2bin; -use function is_numeric; use function preg_replace; -use function str_replace; use function str_starts_with; use function substr; diff --git a/tests/Provider/ColumnFactoryProvider.php b/tests/Provider/ColumnFactoryProvider.php index 0c315f7c..d1c96a50 100644 --- a/tests/Provider/ColumnFactoryProvider.php +++ b/tests/Provider/ColumnFactoryProvider.php @@ -109,7 +109,7 @@ public static function defaultValueRaw(): array $defaultValueRaw[] = [ColumnType::TEXT, 'NULL::"text"', null]; $defaultValueRaw[] = [ColumnType::TEXT, '(NULL)::"text"', null]; $defaultValueRaw[] = [ColumnType::TEXT, "'str''ing'::\"text\"", "str'ing"]; - $defaultValueRaw[] = [ColumnType::TEXT, "'str::ing'::\"text\"", "str::ing"]; + $defaultValueRaw[] = [ColumnType::TEXT, "'str::ing'::\"text\"", 'str::ing']; $defaultValueRaw[] = [ColumnType::INTEGER, '(-1)::"int"', -1]; $defaultValueRaw[] = [ColumnType::BIT, "B'1011'::\"bit\"", 0b1011]; $defaultValueRaw[] = [ColumnType::STRING, "'\\x737472696e67'", '\\x737472696e67']; From ba1e1652a0bf207f2d25051637ce1d8cb1799319 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 02:47:30 +0000 Subject: [PATCH 06/12] Apply Rector changes (CI) --- src/Column/ColumnFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index f03b4f62..9195250c 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -165,7 +165,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche return $column->phpTypecast(substr($value, 2, -1)); } - $value = parent::normalizeNotNullDefaultValue($value, $column); + $value = null; if ($value instanceof Expression) { return new Expression($defaultValue); From 7cc71141ea81e990968a73932832521cdfb91cc5 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 09:58:50 +0700 Subject: [PATCH 07/12] Revert "Apply Rector changes (CI)" This reverts commit ba1e1652a0bf207f2d25051637ce1d8cb1799319. --- src/Column/ColumnFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 9195250c..f03b4f62 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -165,7 +165,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche return $column->phpTypecast(substr($value, 2, -1)); } - $value = null; + $value = parent::normalizeNotNullDefaultValue($value, $column); if ($value instanceof Expression) { return new Expression($defaultValue); From 7c9c4c4005ec6c26b7c7c4c139364dd311135b0b Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 10:01:52 +0700 Subject: [PATCH 08/12] Disable rector --- .github/workflows/{rector.yml => rector_.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{rector.yml => rector_.yml} (100%) diff --git a/.github/workflows/rector.yml b/.github/workflows/rector_.yml similarity index 100% rename from .github/workflows/rector.yml rename to .github/workflows/rector_.yml From f4bcca8d5592a1cfe7410eb743475a3e401ad901 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 03:02:31 +0000 Subject: [PATCH 09/12] Apply Rector changes (CI) --- src/Column/ColumnFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index f03b4f62..9195250c 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -165,7 +165,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche return $column->phpTypecast(substr($value, 2, -1)); } - $value = parent::normalizeNotNullDefaultValue($value, $column); + $value = null; if ($value instanceof Expression) { return new Expression($defaultValue); From 0531540b7c3f536b73edfcc4121651614579e7a3 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 10:04:09 +0700 Subject: [PATCH 10/12] Revert "Apply Rector changes (CI)" This reverts commit f4bcca8d5592a1cfe7410eb743475a3e401ad901. --- src/Column/ColumnFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 9195250c..f03b4f62 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -165,7 +165,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche return $column->phpTypecast(substr($value, 2, -1)); } - $value = null; + $value = parent::normalizeNotNullDefaultValue($value, $column); if ($value instanceof Expression) { return new Expression($defaultValue); From d5135a4ebbd79f57c5df882917ac40a4ee39caa9 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 12 Nov 2024 10:04:28 +0700 Subject: [PATCH 11/12] Disable rector --- .github/workflows/{rector_.yml => rector.yml_} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{rector_.yml => rector.yml_} (100%) diff --git a/.github/workflows/rector_.yml b/.github/workflows/rector.yml_ similarity index 100% rename from .github/workflows/rector_.yml rename to .github/workflows/rector.yml_ From 3c8233bcaecd65f9aa2ccdb8d9ae87b3c2fc2d83 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 16 Nov 2024 09:15:42 +0700 Subject: [PATCH 12/12] Update CHANGELOG.md [skip ci] --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c698b70..a41abec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - Enh #353: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov) - Enh #354: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) - Enh #356: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov) -- New #355, #368: Implement `ColumnFactory` class (@Tigrov) +- New #355, #368, #370: Implement `ColumnFactory` class (@Tigrov) - Enh #359: Separate column type constants (@Tigrov) - Enh #359: Remove `Schema::TYPE_ARRAY` and `Schema::TYPE_STRUCTURED` constants (@Tigrov) - New #360: Realize `ColumnBuilder` class (@Tigrov) @@ -19,6 +19,7 @@ - New #364: Add `ColumnDefinitionBuilder` class (@Tigrov) - Enh #365: Refactor `Dsn` class (@Tigrov) - Enh #366: Use constructor to create columns and initialize properties (@Tigrov) +- Enh #370: Refactor `Schema::normalizeDefaultValue()` method and move it to `ColumnFactory` class (@Tigrov) ## 1.3.0 March 21, 2024