diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0cb149b..0f70d0e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: - 8.2 - 8.3 - 8.4 + - 8.5 mssql: - 2022-latest diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 1face1f2..2f8aece6 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -25,6 +25,6 @@ jobs: uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master with: php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] required-packages: >- ['db'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 547990de..53343e8d 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -34,7 +34,7 @@ jobs: - ubuntu-latest php: - - 8.4 + - 8.5 services: mssql: @@ -67,8 +67,8 @@ jobs: ini-values: memory_limit=-1 coverage: pcov - - name: Update composer. - run: composer self-update + - name: Install Composer dependencies + uses: ramsey/composer-install@v3 - name: Install db. uses: yiisoft/actions/install-packages@master diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml index 3c670a95..d6a42ee5 100644 --- a/.github/workflows/rector-cs.yml +++ b/.github/workflows/rector-cs.yml @@ -24,6 +24,6 @@ jobs: token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: repository: ${{ github.event.pull_request.head.repo.full_name }} - php: '8.4' + php: '8.5' required-packages: >- ['db'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 92274817..7f493dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ - New #339: Add `IndexType` and `IndexMethod` classes (@Tigrov) - Bug #343: Explicitly mark nullable parameters (@vjik) - New #342, #405: Support JSON type (@Tigrov) -- Chg #344: Change supported PHP versions to `8.1 - 8.4` (@Tigrov) +- Chg #344, #418: Change supported PHP versions to `8.1 - 8.5` (@Tigrov, @vjik) - Chg #344: Change return type of `Command::insertWithReturningPks()` method to `array|false` (@Tigrov) - New #345: Add parameters `$ifExists` and `$cascade` to `CommandInterface::dropTable()` and `DDLQueryBuilderInterface::dropTable()` methods (@vjik) @@ -63,6 +63,7 @@ - Bug #408, #409: Add `identity` support in `Schema::loadResultColumn()` (@vjik) - Chg #413: Throw exception on "unsigned" column usage (@vjik) - New #415: Add enumeration column type support (@vjik) +- New #418: Trim dot in column default value normalization to prevent PHP 8.5+ warnings on large values (@vjik) ## 1.2.0 March 21, 2024 diff --git a/README.md b/README.md index 43cde689..8d9b45f6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Driver supports Microsoft SQL Server 2017 or higher. ## Requirements -- PHP 8.1 - 8.4. +- PHP 8.1 - 8.5. - `pdo_sqlsrv` PHP extension. ## Installation diff --git a/composer.json b/composer.json index 2f5544ec..10b05426 100644 --- a/composer.json +++ b/composer.json @@ -31,18 +31,17 @@ } ], "require": { - "php": "8.1 - 8.4", + "php": "8.1 - 8.5", "ext-pdo": "*", "yiisoft/db": "dev-master" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.3", "friendsofphp/php-cs-fixer": "^3.89.1", "maglnet/composer-require-checker": "^4.7.1", "phpunit/phpunit": "^10.5.45", "rector/rector": "^2.0.10", - "roave/infection-static-analysis-plugin": "^1.35", "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.8.8", "vlucas/phpdotenv": "^5.6.1", "yiisoft/aliases": "^2.0", "yiisoft/psr-dummy-provider": "^1.0", @@ -64,10 +63,17 @@ }, "files": ["tests/bootstrap.php"] }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "target-directory": "tools", + "forward-command": true + } + }, "config": { "sort-packages": true, "allow-plugins": { - "infection/extension-installer": true, + "bamarni/composer-bin-plugin": true, "composer/package-versions-deprecated": true } }, diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 698e0eb5..0ee03f3c 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -115,6 +115,10 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte return hex2bin(substr($defaultValue, 2)); } + if (preg_match('~^\((\d+)\.\)$~', $defaultValue, $matches) === 1) { + return $column->phpTypecast($matches[1]); + } + return parent::normalizeNotNullDefaultValue($defaultValue, $column); } } diff --git a/tests/ColumnFactoryTest.php b/tests/ColumnFactoryTest.php index 2930f3cf..9424fba8 100644 --- a/tests/ColumnFactoryTest.php +++ b/tests/ColumnFactoryTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\Attributes\DataProviderExternal; use Yiisoft\Db\Mssql\Column\ColumnFactory; use Yiisoft\Db\Mssql\Tests\Provider\ColumnFactoryProvider; +use Yiisoft\Db\Mssql\Tests\Support\IntegrationTestTrait; use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Tests\Common\CommonColumnFactoryTest; @@ -15,6 +16,8 @@ */ final class ColumnFactoryTest extends CommonColumnFactoryTest { + use IntegrationTestTrait; + #[DataProviderExternal(ColumnFactoryProvider::class, 'dbTypes')] public function testFromDbType(string $dbType, string $expectedType, string $expectedInstanceOf): void { diff --git a/tests/Type/BigIntTest.php b/tests/Type/BigIntTest.php index b74779a5..eac3cb33 100644 --- a/tests/Type/BigIntTest.php +++ b/tests/Type/BigIntTest.php @@ -82,49 +82,6 @@ public function testDefaultValueWithInsert(): void $db->createCommand()->dropTable('bigint_default')->execute(); } - /** - * Max value is `9223372036854775807`, but when the value is greater than `9223372036854775807` it is out of range - * and save as `9223372036854775807`. - */ - public function testMaxValue(): void - { - $db = $this->getSharedConnection(); - $this->loadFixture(FixtureDump::TYPE_BIGINT); - - $command = $db->createCommand(); - $command->insert('bigint', ['Mybigint1' => '9223372036854775807', 'Mybigint2' => '0'])->execute(); - - $this->assertSame( - [ - 'id' => '1', - 'Mybigint1' => '9223372036854775807', - 'Mybigint2' => '0', - ], - $command->setSql( - <<queryOne(), - ); - - $command->insert('bigint', ['Mybigint1' => '9223372036854775808', 'Mybigint2' => null])->execute(); - - $this->assertSame( - [ - 'id' => '2', - 'Mybigint1' => '9223372036854775807', - 'Mybigint2' => null, - ], - $command->setSql( - <<queryOne(), - ); - - $db->createCommand()->dropTable('bigint')->execute(); - } - /** * Min value is `-9223372036854775808`, but when the value is less than `-9223372036854775808` it is out of range * and save as `-9223372036854775808`. diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 00000000..cf452dcf --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,2 @@ +/*/vendor +/*/composer.lock diff --git a/tools/infection/composer.json b/tools/infection/composer.json new file mode 100644 index 00000000..18be2ea1 --- /dev/null +++ b/tools/infection/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "infection/infection": "^0.26 || ^0.31.9" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +} diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json new file mode 100644 index 00000000..44e11e3e --- /dev/null +++ b/tools/psalm/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "vimeo/psalm": "^5.26.1 || ^6.8.8" + } +}