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

Address API removals from upstream #9885

Merged
merged 22 commits into from
Jul 13, 2022
Merged

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Jul 7, 2022

doctrine/dbal#5477 has removed 2 things:

  • array and object types
  • custom schema options

ThomasLandauer and others added 9 commits June 28, 2022 23:44
When I introduced OrmFunctionalTestCase::createSchemaForModels(), I made
several wrong assumptions:
- the call is always wrapped in a try / catch;
- that try / catch is always typed with "Exception".

Because of that, I missed, many, many occurrences of
SchemaTool::createSchema().

I recently noticed that contributors kept using the
SchemaTool::createSchema() and figured not everything had been
migrated.

Migrating some of them did not result in something far better until I
also introduced similar methods for
SchemaTool::getUpdateSchemaSql() and SchemaTool::getSchemaFromMetadata().
Migrate more usages of SchemaTool::createSchema()
*FlushEventArgs classes should extend ManagerEventArgs from
doctrine/persistence to be able to use ManagerEventArgs for any
persistance implementation.

OnClearEventArgs should extend from OnClearEventArgs from
doctrine/persistence.
If ObjectHydrator faces an empty row to an uninitialized collection,
it initializes it, to prevent it from querying again (DDC-1526).
However, if that row is the first but not the only in the collection,
the next rows will be ignored, as the collection will be considered
"existing", and "existing" collections are only replaced if REFRESH hint
is present. To prevent it, we defer initialization to the end of the
hydration.

Fixes doctrineGH-9807
[doctrineGH-9807] Fix: initialize potentially empty collections at the hydration complete
@greg0ire greg0ire force-pushed the fix-build branch 3 times, most recently from 9495bb8 to 8c43b3d Compare July 7, 2022 21:37
@greg0ire
Copy link
Member Author

greg0ire commented Jul 7, 2022

The removal of custom schema options seems to break the code introduced in #9655 for some reason…

derrabus added 2 commits July 8, 2022 13:53
* 2.12.x:
  PHPStan 1.8.0 (doctrine#9887)
  Fix typo in AbstractQuery
  ObjectHydrator: defer initialization of potentially empty collections
  Migrate more usages of SchemaTool::createSchema()
  preUpdate: Add restriction that changed field needs to be in computed changeset (doctrine#9871)
@greg0ire
Copy link
Member Author

greg0ire commented Jul 9, 2022

@ruudk @morozov maybe you can help with this failure: https://github.com/doctrine/orm/runs/7242015946?check_suite_focus=true#step:7:79

I don't understand what's happening, but I think it must be somehow related to custom schema options. The original PR of @ruudk relied on them: #9636 , but not the second one: #9655

final protected function assertQueryLog(string ...$expectedQueries): void
{
self::assertSame($expectedQueries, array_column($this->getQueryLog()->queries, 'sql'));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Introducing that method allows to compare the 2 query logs rather than getting an exception because there is no seventh query.

@greg0ire
Copy link
Member Author

greg0ire commented Jul 9, 2022

but not the second one: #9655

Custom options are not mentioned in the code, but they are mentioned in the summary of that PR though 🤔

UPD: I think this line is throwing away the extra options:

$options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS));

Before my changes, there was a separation into known options and custom ones: https://github.com/doctrine/orm/blob/2.12.x/lib/Doctrine/ORM/Tools/SchemaTool.php#L799-L800

Removing that breaks the test suite because of how enum types are implemented, but that might be the way to go, I'll have to investigate why that separation was needed in the first place.

The issue with the test suite is related to #9382

Now it blows up with The "enumType" column option is not supported., thrown here: https://github.com/doctrine/dbal/blob/2485d0a49dd17d05f54b68bb020eced4242388c8/src/Schema/Column.php#L83-L85

@morozov , what's the upgrade path for this?

UPD: nevermind, I think I've found what needed to be done.

@greg0ire
Copy link
Member Author

greg0ire commented Jul 9, 2022

The build is green, but I'm not setting this as ready for review yet: there are things I can backport, and other things that might be incorrect.

greg0ire added 4 commits July 10, 2022 11:22
SerializationModel has a field with type array, and another with type
object. Both types are deprecated.
It contains fields with deprecated types.
…ype-deprecation

Address array object type deprecation
$options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS));
$options['customSchemaOptions'] = array_diff_key($mappingOptions, $options);
$options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS));
$options['platformOptions'] = array_diff_key($mappingOptions, $options);
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if I should backport this as well… Column::getCustomSchemaOptions() will not return the same thing as previously, not sure how acceptable that is.

Copy link
Member

@morozov morozov Jul 10, 2022

Choose a reason for hiding this comment

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

I'd leave it as is in older branches. This API is supported up until DBAL 4.0, so there's no reason to break anything prior to supporting it.

@greg0ire greg0ire force-pushed the fix-build branch 2 times, most recently from 27fa390 to 3bd0427 Compare July 12, 2022 18:14
@greg0ire
Copy link
Member Author

I've backported what was reasonable to backport; this is now the combination of a merge-up and fixes for the build (which are in separate commits)

@greg0ire greg0ire marked this pull request as ready for review July 12, 2022 20:38
@greg0ire greg0ire requested a review from morozov July 12, 2022 20:38
@greg0ire greg0ire merged commit 990a1fe into doctrine:3.0.x Jul 13, 2022
@greg0ire greg0ire deleted the fix-build branch July 13, 2022 10:10
@derrabus derrabus added this to the 3.0.0 milestone Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants