Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 3.8.x up into 4.0.x #6378

Merged
merged 22 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d43c897
Specify the minor version number
greg0ire May 1, 2024
cbde0fd
Merge pull request #6373 from greg0ire/fix-build
greg0ire May 1, 2024
8b99c83
Set fail_ci_if_error flag to true
greg0ire May 1, 2024
27eb261
Upgrade to codecov/codecov-action v4
greg0ire May 1, 2024
ba7dbe1
Merge pull request #6372 from greg0ire/sensible-status-code-codecov
greg0ire May 2, 2024
e7c9102
Provide CODECOV_TOKEN
greg0ire May 2, 2024
7342bad
Merge pull request #6374 from doctrine/fix-upload
greg0ire May 2, 2024
008a802
Fix SQLite temp table name must not contain dot (#6315)
mvorisek May 3, 2024
bc75742
Fix DB name passing in SqliteSchemaManager::listTableForeignKeys() (#…
mvorisek May 3, 2024
8c57598
Merge remote-tracking branch 'origin/3.8.x' into 4.0.x
greg0ire May 3, 2024
40e7b7c
Fix SQL Server "extended property" SQL generation (#6353)
mvorisek May 3, 2024
381f304
Bump workflow actions
greg0ire May 3, 2024
1c487b9
Merge pull request #6379 from greg0ire/bump-ci-workflow
greg0ire May 3, 2024
5351005
fix merge
mvorisek May 4, 2024
e13e34c
Merge pull request #7 from mvorisek/merge_4
greg0ire May 4, 2024
454de1e
Switch to substr implementation
greg0ire May 4, 2024
e509c5b
Fix SQLiteSchemaManagerTest case
greg0ire May 4, 2024
50ef60d
Merge remote-tracking branch 'origin/4.0.x' into 4.0.x
greg0ire May 4, 2024
8fd3868
Setup dependabot
greg0ire May 4, 2024
55106a4
Merge pull request #6383 from greg0ire/setup-dependabot
greg0ire May 4, 2024
f2f883c
Use 3.8.x as a target for dependabot version updates (#6384)
greg0ire May 5, 2024
df67ea3
Merge remote-tracking branch 'origin/3.8.x' into 4.0.x
greg0ire May 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.0"
23 changes: 13 additions & 10 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 @@ -328,7 +328,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 @@ -399,7 +399,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 @@ -470,7 +470,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 @@ -541,7 +541,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 @@ -576,7 +576,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 @@ -612,6 +612,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
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 @@
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)

Check warning on line 265 in src/Platforms/SQLServerPlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/SQLServerPlatform.php#L265

Added line #L265 was not covered by tests
: $possiblyQuotedName;
}

/**
* Returns the SQL statement for creating a column comment.
*
Expand All @@ -274,23 +284,20 @@
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 @@
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 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 @@
?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 @@
): 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 @@
?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 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
2 changes: 1 addition & 1 deletion src/Schema/SQLiteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function listTableForeignKeys(string $table): array
{
$table = $this->normalizeName($table);

$columns = $this->selectForeignKeyColumns('', $table)
$columns = $this->selectForeignKeyColumns('main', $table)
->fetchAllAssociative();

if (count($columns) > 0) {
Expand Down
21 changes: 21 additions & 0 deletions tests/Functional/Schema/SQLiteSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

use function array_keys;
use function array_shift;

class SQLiteSchemaManagerTest extends SchemaManagerFunctionalTestCase
Expand Down Expand Up @@ -207,6 +210,24 @@ public function testNonSimpleAlterTableCreatedFromDDL(): void
self::assertSame(['name'], $index->getColumns());
}

public function testAlterTableWithSchema(): void
{
$this->dropTableIfExists('t');

$table = new Table('main.t');
$table->addColumn('a', Types::INTEGER);
$this->schemaManager->createTable($table);

self::assertSame(['a'], array_keys($this->schemaManager->listTableColumns('t')));

$tableDiff = new TableDiff($table, [], [], [], [
'a' => new Column('b', Type::getType(Types::INTEGER)),
], [], [], [], [], [], [], []);
$this->schemaManager->alterTable($tableDiff);

self::assertSame(['b'], array_keys($this->schemaManager->listTableColumns('t')));
}

public function testIntrospectMultipleAnonymousForeignKeyConstraints(): void
{
$this->dropTableIfExists('album');
Expand Down