Skip to content

Commit a96c52c

Browse files
committed
Merge branch '4.1.x' into 5.0.x
* 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
2 parents 542c463 + c08b988 commit a96c52c

14 files changed

+172
-73
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- "CI"
9+
target-branch: "3.8.x"

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ on:
2525
jobs:
2626
coding-standards:
2727
name: "Coding Standards"
28-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@4.0.0"
28+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.0.1"

.github/workflows/continuous-integration.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
ini-values: "zend.assertions=1"
6969

7070
- name: "Install dependencies with Composer"
71-
uses: "ramsey/composer-install@v2"
71+
uses: "ramsey/composer-install@v3"
7272
with:
7373
composer-options: "--ignore-platform-req=php+"
7474
dependency-versions: "${{ matrix.dependencies }}"
@@ -136,7 +136,7 @@ jobs:
136136
ini-values: "zend.assertions=1"
137137

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

@@ -193,7 +193,7 @@ jobs:
193193
ini-values: "zend.assertions=1"
194194

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

@@ -257,7 +257,7 @@ jobs:
257257
ini-values: "zend.assertions=1"
258258

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

@@ -327,7 +327,7 @@ jobs:
327327
extensions: "${{ matrix.extension }}"
328328

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

@@ -351,7 +351,6 @@ jobs:
351351
- "8.1"
352352
mysql-version:
353353
- "8.0"
354-
- "8.3"
355354
extension:
356355
- "mysqli"
357356
- "pdo_mysql"
@@ -368,6 +367,16 @@ jobs:
368367
- php-version: "8.3"
369368
mysql-version: "8.0"
370369
extension: "pdo_mysql"
370+
- php-version: "8.1"
371+
mysql-version: "8.4"
372+
extension: "mysqli"
373+
custom-entrypoint: >-
374+
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
375+
- php-version: "8.1"
376+
mysql-version: "8.4"
377+
extension: "pdo_mysql"
378+
custom-entrypoint: >-
379+
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
371380
372381
services:
373382
mysql:
@@ -397,7 +406,7 @@ jobs:
397406
extensions: "${{ matrix.extension }}"
398407

399408
- name: "Install dependencies with Composer"
400-
uses: "ramsey/composer-install@v2"
409+
uses: "ramsey/composer-install@v3"
401410
with:
402411
composer-options: "--ignore-platform-req=php+"
403412

@@ -468,7 +477,7 @@ jobs:
468477
extensions: "${{ matrix.extension }}-5.10.0beta1"
469478

470479
- name: "Install dependencies with Composer"
471-
uses: "ramsey/composer-install@v2"
480+
uses: "ramsey/composer-install@v3"
472481
with:
473482
composer-options: "--ignore-platform-req=php+"
474483

@@ -539,7 +548,7 @@ jobs:
539548
IBM_DB2_CONFIGURE_OPTS: "--with-IBM_DB2=/tmp/clidriver"
540549

541550
- name: "Install dependencies with Composer"
542-
uses: "ramsey/composer-install@v2"
551+
uses: "ramsey/composer-install@v3"
543552
with:
544553
composer-options: "--ignore-platform-req=php+"
545554

@@ -574,7 +583,7 @@ jobs:
574583
run: "composer config minimum-stability dev"
575584

576585
- name: "Install development dependencies with Composer"
577-
uses: "ramsey/composer-install@v2"
586+
uses: "ramsey/composer-install@v3"
578587
with:
579588
composer-options: "--prefer-dist"
580589

@@ -610,6 +619,9 @@ jobs:
610619
working-directory: reports
611620

612621
- name: "Upload to Codecov"
613-
uses: "codecov/codecov-action@v3"
622+
uses: "codecov/codecov-action@v4"
614623
with:
615624
directory: reports
625+
fail_ci_if_error: true
626+
env:
627+
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"

.github/workflows/lock-closed-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
lock:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: dessant/lock-threads@v3
11+
- uses: dessant/lock-threads@v5
1212
with:
1313
github-token: '${{ github.token }}'
1414
issue-inactive-days: 30

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
tools: "cs2pr"
4949

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

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

7676
- name: Install dependencies with Composer
77-
uses: ramsey/composer-install@v2
77+
uses: ramsey/composer-install@v3
7878

7979
- name: Run static analysis with Vimeo Psalm
8080
run: vendor/bin/psalm --shepherd

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
"doctrine/coding-standard": "12.0.0",
4141
"fig/log-test": "^1",
4242
"jetbrains/phpstorm-stubs": "2023.2",
43-
"phpstan/phpstan": "1.10.58",
44-
"phpstan/phpstan-phpunit": "1.3.15",
43+
"phpstan/phpstan": "1.10.67",
44+
"phpstan/phpstan-phpunit": "1.3.16",
4545
"phpstan/phpstan-strict-rules": "^1.5",
4646
"phpunit/phpunit": "10.5.9",
4747
"psalm/plugin-phpunit": "0.18.4",
4848
"slevomat/coding-standard": "8.13.1",
49-
"squizlabs/php_codesniffer": "3.9.0",
49+
"squizlabs/php_codesniffer": "3.9.2",
5050
"symfony/cache": "^6.3.8|^7.0",
5151
"symfony/console": "^5.4|^6.3|^7.0",
5252
"vimeo/psalm": "5.21.1"

src/Platforms/SQLServerPlatform.php

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
use function preg_match_all;
3535
use function sprintf;
3636
use function str_contains;
37+
use function str_ends_with;
3738
use function str_replace;
39+
use function str_starts_with;
3840
use function strtoupper;
41+
use function substr;
3942
use function substr_count;
4043

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

262+
private function unquoteSingleIdentifier(string $possiblyQuotedName): string
263+
{
264+
return str_starts_with($possiblyQuotedName, '[') && str_ends_with($possiblyQuotedName, ']')
265+
? substr($possiblyQuotedName, 1, -1)
266+
: $possiblyQuotedName;
267+
}
268+
259269
/**
260270
* Returns the SQL statement for creating a column comment.
261271
*
@@ -274,23 +284,20 @@ public function getCreatePrimaryKeySQL(Index $index, string $table): string
274284
protected function getCreateColumnCommentSQL(string $tableName, string $columnName, string $comment): string
275285
{
276286
if (str_contains($tableName, '.')) {
277-
[$schemaSQL, $tableSQL] = explode('.', $tableName);
278-
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
279-
$tableSQL = $this->quoteStringLiteral($tableSQL);
287+
[$schemaName, $tableName] = explode('.', $tableName);
280288
} else {
281-
$schemaSQL = "'dbo'";
282-
$tableSQL = $this->quoteStringLiteral($tableName);
289+
$schemaName = 'dbo';
283290
}
284291

285292
return $this->getAddExtendedPropertySQL(
286293
'MS_Description',
287294
$comment,
288295
'SCHEMA',
289-
$schemaSQL,
296+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
290297
'TABLE',
291-
$tableSQL,
298+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
292299
'COLUMN',
293-
$columnName,
300+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
294301
);
295302
}
296303

@@ -568,23 +575,20 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff
568575
protected function getAlterColumnCommentSQL(string $tableName, string $columnName, string $comment): string
569576
{
570577
if (str_contains($tableName, '.')) {
571-
[$schemaSQL, $tableSQL] = explode('.', $tableName);
572-
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
573-
$tableSQL = $this->quoteStringLiteral($tableSQL);
578+
[$schemaName, $tableName] = explode('.', $tableName);
574579
} else {
575-
$schemaSQL = "'dbo'";
576-
$tableSQL = $this->quoteStringLiteral($tableName);
580+
$schemaName = 'dbo';
577581
}
578582

579583
return $this->getUpdateExtendedPropertySQL(
580584
'MS_Description',
581585
$comment,
582586
'SCHEMA',
583-
$schemaSQL,
587+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
584588
'TABLE',
585-
$tableSQL,
589+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
586590
'COLUMN',
587-
$columnName,
591+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
588592
);
589593
}
590594

@@ -605,22 +609,19 @@ protected function getAlterColumnCommentSQL(string $tableName, string $columnNam
605609
protected function getDropColumnCommentSQL(string $tableName, string $columnName): string
606610
{
607611
if (str_contains($tableName, '.')) {
608-
[$schemaSQL, $tableSQL] = explode('.', $tableName);
609-
$schemaSQL = $this->quoteStringLiteral($schemaSQL);
610-
$tableSQL = $this->quoteStringLiteral($tableSQL);
612+
[$schemaName, $tableName] = explode('.', $tableName);
611613
} else {
612-
$schemaSQL = "'dbo'";
613-
$tableSQL = $this->quoteStringLiteral($tableName);
614+
$schemaName = 'dbo';
614615
}
615616

616617
return $this->getDropExtendedPropertySQL(
617618
'MS_Description',
618619
'SCHEMA',
619-
$schemaSQL,
620+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($schemaName)),
620621
'TABLE',
621-
$tableSQL,
622+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
622623
'COLUMN',
623-
$columnName,
624+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($columnName)),
624625
);
625626
}
626627

@@ -663,10 +664,13 @@ protected function getAddExtendedPropertySQL(
663664
?string $level2Name = null,
664665
): string {
665666
return 'EXEC sp_addextendedproperty ' .
666-
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' .
667-
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
668-
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
669-
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
667+
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral($value ?? '') . ', ' .
668+
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
669+
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
670+
($level2Type !== null || $level2Name !== null
671+
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
672+
: ''
673+
);
670674
}
671675

672676
/**
@@ -693,9 +697,12 @@ protected function getDropExtendedPropertySQL(
693697
): string {
694698
return 'EXEC sp_dropextendedproperty ' .
695699
'N' . $this->quoteStringLiteral($name) . ', ' .
696-
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
697-
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
698-
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
700+
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
701+
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
702+
($level2Type !== null || $level2Name !== null
703+
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
704+
: ''
705+
);
699706
}
700707

701708
/**
@@ -723,10 +730,13 @@ protected function getUpdateExtendedPropertySQL(
723730
?string $level2Name = null,
724731
): string {
725732
return 'EXEC sp_updateextendedproperty ' .
726-
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' .
727-
'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' .
728-
'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' .
729-
'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name;
733+
'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral($value ?? '') . ', ' .
734+
'N' . $this->quoteStringLiteral($level0Type ?? '') . ', ' . $level0Name . ', ' .
735+
'N' . $this->quoteStringLiteral($level1Type ?? '') . ', ' . $level1Name .
736+
($level2Type !== null || $level2Name !== null
737+
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
738+
: ''
739+
);
730740
}
731741

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

11691179
protected function getCommentOnTableSQL(string $tableName, string $comment): string
11701180
{
1171-
return sprintf(
1172-
<<<'SQL'
1173-
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
1174-
@value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo',
1175-
@level1type=N'TABLE', @level1name=N%s
1176-
SQL
1177-
,
1178-
$this->quoteStringLiteral($comment),
1179-
$this->quoteStringLiteral($tableName),
1181+
return $this->getAddExtendedPropertySQL(
1182+
'MS_Description',
1183+
$comment,
1184+
'SCHEMA',
1185+
$this->quoteStringLiteral('dbo'),
1186+
'TABLE',
1187+
$this->quoteStringLiteral($this->unquoteSingleIdentifier($tableName)),
11801188
);
11811189
}
11821190

src/Platforms/SQLitePlatform.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use function str_replace;
3737
use function strpos;
3838
use function strtolower;
39+
use function substr;
3940
use function trim;
4041

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

677-
$dataTable = new Table('__temp__' . $table->getName());
678+
$tableName = $table->getName();
679+
$pos = strpos($tableName, '.');
680+
if ($pos !== false) {
681+
$tableName = substr($tableName, $pos + 1);
682+
}
683+
684+
$dataTable = new Table('__temp__' . $tableName);
678685

679686
$newTable = new Table(
680687
$table->getQuotedName($this),

0 commit comments

Comments
 (0)