Skip to content

Commit

Permalink
Merge branch '4.1.x' into 5.0.x
Browse files Browse the repository at this point in the history
* 4.1.x:
  Fix example for QB delete and update in doc block
  Bump doctrine/.github from 5.0.0 to 5.0.1 (#6391)
  PHPStan 1.10.67, PHPUnit 9.6.19, PHPCS 3.9.2 (#6387)
  Fix "Plugin 'mysql_native_password' is not loaded" (#6388)
  Run tests against MySQL 8.4 (#6386)
  Use 3.8.x as a target for dependabot version updates (#6384)
  Setup dependabot
  Fix SQLiteSchemaManagerTest case
  Switch to substr implementation
  fix merge
  Bump workflow actions
  Fix SQL Server "extended property" SQL generation (#6353)
  Fix DB name passing in SqliteSchemaManager::listTableForeignKeys() (#6338)
  Fix SQLite temp table name must not contain dot (#6315)
  Provide CODECOV_TOKEN
  Upgrade to codecov/codecov-action v4
  Set fail_ci_if_error flag to true
  Specify the minor version number
  • Loading branch information
derrabus committed May 16, 2024
2 parents 542c463 + c08b988 commit a96c52c
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 73 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "CI"
target-branch: "3.8.x"
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@4.0.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.0.1"
34 changes: 23 additions & 11 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"
dependency-versions: "${{ matrix.dependencies }}"
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -327,7 +327,7 @@ jobs:
extensions: "${{ matrix.extension }}"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand All @@ -351,7 +351,6 @@ jobs:
- "8.1"
mysql-version:
- "8.0"
- "8.3"
extension:
- "mysqli"
- "pdo_mysql"
Expand All @@ -368,6 +367,16 @@ jobs:
- php-version: "8.3"
mysql-version: "8.0"
extension: "pdo_mysql"
- php-version: "8.1"
mysql-version: "8.4"
extension: "mysqli"
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
- php-version: "8.1"
mysql-version: "8.4"
extension: "pdo_mysql"
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
services:
mysql:
Expand Down Expand Up @@ -397,7 +406,7 @@ jobs:
extensions: "${{ matrix.extension }}"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -468,7 +477,7 @@ jobs:
extensions: "${{ matrix.extension }}-5.10.0beta1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -539,7 +548,7 @@ jobs:
IBM_DB2_CONFIGURE_OPTS: "--with-IBM_DB2=/tmp/clidriver"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

Expand Down Expand Up @@ -574,7 +583,7 @@ jobs:
run: "composer config minimum-stability dev"

- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--prefer-dist"

Expand Down Expand Up @@ -610,6 +619,9 @@ jobs:
working-directory: reports

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v3"
uses: "codecov/codecov-action@v4"
with:
directory: reports
fail_ci_if_error: true
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v3
- uses: dessant/lock-threads@v5
with:
github-token: '${{ github.token }}'
issue-inactive-days: 30
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
tools: "cs2pr"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"
Expand All @@ -74,7 +74,7 @@ jobs:
tools: cs2pr

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run static analysis with Vimeo Psalm
run: vendor/bin/psalm --shepherd
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"doctrine/coding-standard": "12.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.2",
"phpstan/phpstan": "1.10.58",
"phpstan/phpstan-phpunit": "1.3.15",
"phpstan/phpstan": "1.10.67",
"phpstan/phpstan-phpunit": "1.3.16",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "10.5.9",
"psalm/plugin-phpunit": "0.18.4",
"slevomat/coding-standard": "8.13.1",
"squizlabs/php_codesniffer": "3.9.0",
"squizlabs/php_codesniffer": "3.9.2",
"symfony/cache": "^6.3.8|^7.0",
"symfony/console": "^5.4|^6.3|^7.0",
"vimeo/psalm": "5.21.1"
Expand Down
96 changes: 52 additions & 44 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
use function preg_match_all;
use function sprintf;
use function str_contains;
use function str_ends_with;
use function str_replace;
use function str_starts_with;
use function strtoupper;
use function substr;
use function substr_count;

use const PREG_OFFSET_CAPTURE;
Expand Down Expand Up @@ -256,6 +259,13 @@ public function getCreatePrimaryKeySQL(Index $index, string $table): string
return $sql . ' (' . implode(', ', $index->getQuotedColumns($this)) . ')';
}

private function unquoteSingleIdentifier(string $possiblyQuotedName): string
{
return str_starts_with($possiblyQuotedName, '[') && str_ends_with($possiblyQuotedName, ']')
? substr($possiblyQuotedName, 1, -1)
: $possiblyQuotedName;
}

/**
* Returns the SQL statement for creating a column comment.
*
Expand All @@ -274,23 +284,20 @@ public function getCreatePrimaryKeySQL(Index $index, string $table): string
protected function getCreateColumnCommentSQL(string $tableName, string $columnName, string $comment): string
{
if (str_contains($tableName, '.')) {
[$schemaSQL, $tableSQL] = explode('.', $tableName);
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
$tableSQL = $this->quoteStringLiteral($tableSQL);
[$schemaName, $tableName] = explode('.', $tableName);
} else {
$schemaSQL = "'dbo'";
$tableSQL = $this->quoteStringLiteral($tableName);
$schemaName = 'dbo';
}

return $this->getAddExtendedPropertySQL(
'MS_Description',
$comment,
'SCHEMA',
$schemaSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
'TABLE',
$tableSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
'COLUMN',
$columnName,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
);
}

Expand Down Expand Up @@ -568,23 +575,20 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff
protected function getAlterColumnCommentSQL(string $tableName, string $columnName, string $comment): string
{
if (str_contains($tableName, '.')) {
[$schemaSQL, $tableSQL] = explode('.', $tableName);
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
$tableSQL = $this->quoteStringLiteral($tableSQL);
[$schemaName, $tableName] = explode('.', $tableName);
} else {
$schemaSQL = "'dbo'";
$tableSQL = $this->quoteStringLiteral($tableName);
$schemaName = 'dbo';
}

return $this->getUpdateExtendedPropertySQL(
'MS_Description',
$comment,
'SCHEMA',
$schemaSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
'TABLE',
$tableSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
'COLUMN',
$columnName,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
);
}

Expand All @@ -605,22 +609,19 @@ protected function getAlterColumnCommentSQL(string $tableName, string $columnNam
protected function getDropColumnCommentSQL(string $tableName, string $columnName): string
{
if (str_contains($tableName, '.')) {
[$schemaSQL, $tableSQL] = explode('.', $tableName);
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
$tableSQL = $this->quoteStringLiteral($tableSQL);
[$schemaName, $tableName] = explode('.', $tableName);
} else {
$schemaSQL = "'dbo'";
$tableSQL = $this->quoteStringLiteral($tableName);
$schemaName = 'dbo';
}

return $this->getDropExtendedPropertySQL(
'MS_Description',
'SCHEMA',
$schemaSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
'TABLE',
$tableSQL,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
'COLUMN',
$columnName,
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
);
}

Expand Down Expand Up @@ -663,10 +664,13 @@ protected function getAddExtendedPropertySQL(
?string $level2Name = null,
): string {
return 'EXEC sp_addextendedproperty ' .
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' .
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral($value ?? '') . ', ' .
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
($level2Type !== null || $level2Name !== null
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
: ''
);
}

/**
Expand All @@ -693,9 +697,12 @@ protected function getDropExtendedPropertySQL(
): string {
return 'EXEC sp_dropextendedproperty ' .
'N' . $this->quoteStringLiteral($name) . ', ' .
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
($level2Type !== null || $level2Name !== null
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
: ''
);
}

/**
Expand Down Expand Up @@ -723,10 +730,13 @@ protected function getUpdateExtendedPropertySQL(
?string $level2Name = null,
): string {
return 'EXEC sp_updateextendedproperty ' .
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' .
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral($value ?? '') . ', ' .
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
($level2Type !== null || $level2Name !== null
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
: ''
);
}

public function getEmptyIdentityInsertSQL(string $quotedTableName, string $quotedIdentifierColumnName): string
Expand Down Expand Up @@ -1168,15 +1178,13 @@ protected function getLikeWildcardCharacters(): string

protected function getCommentOnTableSQL(string $tableName, string $comment): string
{
return sprintf(
<<<'SQL'
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N%s
SQL
,
$this->quoteStringLiteral($comment),
$this->quoteStringLiteral($tableName),
return $this->getAddExtendedPropertySQL(
'MS_Description',
$comment,
'SCHEMA',
$this->quoteStringLiteral('dbo'),
'TABLE',
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
);
}

Expand Down
9 changes: 8 additions & 1 deletion src/Platforms/SQLitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use function str_replace;
use function strpos;
use function strtolower;
use function substr;
use function trim;

/**
Expand Down Expand Up @@ -674,7 +675,13 @@ public function getAlterTableSQL(TableDiff $diff): array
$columns[strtolower($column->getName())] = $column;
}

$dataTable = new Table('__temp__' . $table->getName());
$tableName = $table->getName();
$pos = strpos($tableName, '.');
if ($pos !== false) {
$tableName = substr($tableName, $pos + 1);
}

$dataTable = new Table('__temp__' . $tableName);

$newTable = new Table(
$table->getQuotedName($this),
Expand Down

0 comments on commit a96c52c

Please sign in to comment.