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

restore comment hint (useful for enumtype declaration) #6444

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
63429c5
restore comment hint (useful for enumtype declaration)
meiyasan Jun 17, 2024
9c2df18
attempt to fix ci issues
meiyasan Jun 18, 2024
a0273af
fixed native type hint and use preg_match statement in AbstractSchema…
meiyasan Jun 18, 2024
63679e4
reordered use statements + remove useless annotations
meiyasan Jun 18, 2024
25aea71
Merge branch 'doctrine:4.0.x' into 4.0.x
meiyasan Aug 10, 2024
caeb629
fix typo
Lynnaut Aug 31, 2024
d7dc08f
Merge pull request #6514 from Lynnaut/patch-1
greg0ire Sep 1, 2024
ab82363
PDO: Raise a proper exception if user or password is false (#6513)
derrabus Sep 2, 2024
7a82524
Merge branch '3.9.x' into 4.1.x
derrabus Sep 3, 2024
b6eb756
Bump GitHub actions (#6527)
derrabus Sep 30, 2024
8188dd6
ci: Run tests with PHP 8.4 (#6528)
nickvergessen Oct 2, 2024
58c85f0
Mark sidebar as orphan
greg0ire Oct 7, 2024
5188848
Avoid custom directives
greg0ire Oct 7, 2024
6fb2864
Add cli-tools tools document to the TOC
greg0ire Oct 7, 2024
3d9c46c
Setup documentation workflow
greg0ire Oct 7, 2024
5a6ff6f
Fix broken link
greg0ire Oct 7, 2024
aee8c08
Merge pull request #6531 from greg0ire/no-custom-directives
greg0ire Oct 7, 2024
e7202eb
Merge remote-tracking branch 'origin/3.9.x' into 4.1.x
greg0ire Oct 9, 2024
1331d5a
Bump doctrine/.github from 5.1.0 to 5.2.0 (#6534)
dependabot[bot] Oct 9, 2024
1c4fb00
Merge branch '3.9.x' into 4.1.x
derrabus Oct 9, 2024
3098c6b
PHPStan 1.12.6 (#6535)
derrabus Oct 9, 2024
7d93335
CI: remove duplicate key (#6537)
derrabus Oct 9, 2024
dd356be
Merge branch '3.9.x' into 4.1.x
derrabus Oct 9, 2024
db72b7b
Merge branch 'doctrine:4.1.x' into 4.0.x
meiyasan Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function array_map;
use function array_values;
use function count;
use function preg_match;
use function strtolower;

/**
Expand Down Expand Up @@ -129,6 +130,21 @@
);
}

/**
* Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
* the type given as default.
*
* @internal This method should be only used from within the AbstractSchemaManager class hierarchy.
*/
public function extractDoctrineTypeFromComment(?string $comment, string $currentType): string
{
if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match) === 1) {
return $match[1];

Check warning on line 142 in src/Schema/AbstractSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchemaManager.php#L142

Added line #L142 was not covered by tests
}

return $currentType;
}

/**
* Returns true if all the given tables exist.
*
Expand Down
1 change: 1 addition & 0 deletions src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
$precision = null;

$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'] ?? null, $type);

Check warning on line 136 in src/Schema/MySQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/MySQLSchemaManager.php#L136

Added line #L136 was not covered by tests

switch ($dbType) {
case 'char':
Expand Down
1 change: 1 addition & 0 deletions src/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
}

$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'] ?? null, $type);

Check warning on line 138 in src/Schema/OracleSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/OracleSchemaManager.php#L138

Added line #L138 was not covered by tests

switch ($dbType) {
case 'number':
Expand Down
1 change: 1 addition & 0 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
}

$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'] ?? null, $type);

Check warning on line 276 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L276

Added line #L276 was not covered by tests

switch ($dbType) {
case 'smallint':
Expand Down
1 change: 1 addition & 0 deletions src/Schema/SQLServerSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
}

$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'] ?? null, $type);

$options = [
'fixed' => $fixed,
Expand Down
4 changes: 3 additions & 1 deletion src/Schema/SQLiteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@
$unsigned = true;
}

$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'] ?? null, $type);

Check warning on line 245 in src/Schema/SQLiteSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/SQLiteSchemaManager.php#L244-L245

Added lines #L244 - L245 were not covered by tests

$default = $tableColumn['dflt_value'];
if ($default === 'NULL') {
$default = null;
Expand Down