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

Forward compatibility with DBAL 4 #9730

Merged
merged 7 commits into from
May 5, 2022
Merged

Forward compatibility with DBAL 4 #9730

merged 7 commits into from
May 5, 2022

Conversation

@morozov morozov marked this pull request as ready for review May 5, 2022 18:42
@morozov morozov requested review from derrabus and greg0ire May 5, 2022 18:42
*/
private $firstResult = null;
private $firstResult = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This will require a deprecation of setFirstResult(null). The modifyLimitQuery related changes rhis enables are nice!

Copy link
Member Author

@morozov morozov May 5, 2022

Choose a reason for hiding this comment

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

I'd say it's a valid logical next step but not a requirement. From the standpoint of the end result, 0 and null here are and have always been identical, so this patch doesn't change anything about that.

Copy link
Member

Choose a reason for hiding this comment

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

This is actually a breaking change. Symfony's test suite is now failing because Symfony's ORMQueryBuilderLoader checks if getFirstResult() returns null.

Copy link
Member

Choose a reason for hiding this comment

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

Correction: The change on the QueryBuilder is actually the one that breaks Symfony's DoctrineBridge.

Copy link
Member Author

Choose a reason for hiding this comment

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

What part of the API contract does this change break?

Copy link
Member

Choose a reason for hiding this comment

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

It breaks code that does not treat 0 and null as equal. One could argue though that such a piece of code has always been broken or fragile at least.

Here's the fix for Symfony: symfony/symfony#46282

Copy link
Member Author

@morozov morozov May 6, 2022

Choose a reason for hiding this comment

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

No, I specifically mean the API contract. If passed null, the component will do this. If passed a zero, it will do that. What has changed? (Thanks for taking care of that, BTW).

Looking at the patch, I'd say you fixed an existing bug. It existed prior to the change in the ORM and now became reproducible via the existing test suite.

Copy link
Member

Choose a reason for hiding this comment

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

The return value of $em->createQueryBuilder()->getFirstResult() has changed from null to 0. Do we consider this to be part of the API contract? The doc block says we do:

* Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, it's a minor BC break. The proper documentation should have said "Returns NULL or 0..." and the clients should have checked for null or zero. Then this change wouldn't have broken anything.

@morozov morozov mentioned this pull request May 5, 2022
6 tasks
@morozov morozov merged commit e6bda4a into doctrine:2.13.x May 5, 2022
@morozov morozov deleted the dbal-4-compatibility branch May 5, 2022 21:06
@morozov morozov added this to the 2.13.0 milestone May 7, 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.

3 participants