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

require-dev compatibility for Doctrine ORM 3 #2448

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"async-aws/simple-s3": "^1.0",
"aws/aws-sdk-php": "^3.0",
"dama/doctrine-test-bundle": "^8.0.1",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/mongodb-odm": "^2.4",
"doctrine/orm": "^2.14",
"doctrine/orm": "^2.16 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.4",
"knplabs/knp-menu-bundle": "^3.0",
"liip/imagine-bundle": "^2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseMedia.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</field>
<field name="width" column="width" type="integer" nullable="true"/>
<field name="height" column="height" type="integer" nullable="true"/>
<field name="length" column="length" type="decimal" nullable="true"/>
<field name="length" column="length" type="decimal" nullable="true" precision="10"/>
Copy link
Contributor Author

@dmaicher dmaicher Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed with ORM 3. Otherwise will lead to

Doctrine\DBAL\Exception\InvalidColumnType\ColumnPrecisionRequired: Column precision is not specified

https://www.doctrine-project.org/projects/doctrine-dbal/en/4.0/reference/schema-representation.html#portable-options

says

Defaults to 10.

Still going to verify this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema create SQL

ORM 2 without specified precision: length NUMERIC(10, 0) DEFAULT NULL
ORM 3 with specified precision = 10: length NUMERIC(10, 0) DEFAULT NULL

So this change should keep BC

<field name="contentType" column="content_type" type="string" nullable="true" length="255"/>
<field name="size" column="content_size" type="integer" nullable="true"/>
<field name="copyright" column="copyright" type="string" nullable="true"/>
Expand Down
1 change: 1 addition & 0 deletions tests/App/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ doctrine:
orm:
entity_managers:
default:
report_fields_where_declared: true
mappings:
SonataMediaBundle: null
SonataMediaTest:
Expand Down
7 changes: 1 addition & 6 deletions tests/custom_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@
$kernel = new AppKernel($_SERVER['APP_ENV'] ?? 'test', (bool) ($_SERVER['APP_DEBUG'] ?? false));
$application = new Application($kernel);
$application->setAutoExit(false);
$application->setCatchExceptions(false);

$input = new ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => true,
]);
$application->run($input, new NullOutput());

$input = new ArrayInput([
'command' => 'doctrine:database:create',
'--no-interaction' => true,
]);
$application->run($input, new NullOutput());

$input = new ArrayInput([
'command' => 'doctrine:schema:create',
]);
Expand Down
Loading