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

[PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type #54694

Open
wants to merge 1 commit into
base: 5.4
Choose a base branch
from

Conversation

llupa
Copy link
Contributor

@llupa llupa commented Apr 22, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? not sure
Deprecations? no
Issues Fix #54418
License MIT

Additional Considerations

This issue looks pretty straight forward, but it has had me running in circles not being sure how to exactly interpret it. The new return type to make it work with DBAL 4 is fine, but it is neither an intersection nor a union type, which will cause trouble for other libs if they do not explicitly check each.

There is not easy way to get which DBAL version is the extractor is running against, so trying to optimize the flow is tricky. I am opening this PR to have a starting point in the hopes that maintainers of this package have more historical context than me.

I have tried to document as much as possible about this in the issue linked above. 🍻

@carsonbot

This comment was marked as outdated.

@llupa llupa marked this pull request as ready for review April 22, 2024 11:19
@llupa llupa requested a review from dunglas as a code owner April 22, 2024 11:19
@carsonbot carsonbot added this to the 5.4 milestone Apr 22, 2024
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.
Did you check if this applies to branch 5.4 maybe?

@@ -165,7 +165,7 @@ public static function typesProvider(): array
return [
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]], // change? separate for DBAL 3 vs 4?
Copy link
Member

Choose a reason for hiding this comment

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

I suppose yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Sf 5.4 can be paired with ORM3/DBAL4 but IDK if the team wants a separate test for this? I noticed another test had @requires PHP 8.1, I assumed that it would be better to have one with DBAL3 and one with DBAL4.

Copy link
Member

Choose a reason for hiding this comment

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

either separate tests, or just an expectation that changes depending on which version is installed - that'd be fine also

Copy link
Contributor Author

@llupa llupa Apr 23, 2024

Choose a reason for hiding this comment

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

Hey Nicolas,

as Alexander hinted, you can use composer to get installed versions. Do you think this is worth it? Or should I just update the test with a new return expected value?

Copy link
Member

Choose a reason for hiding this comment

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

Let's rather go with a feature test. There must be some class that's unique to one or the other version.

Copy link
Member

Choose a reason for hiding this comment

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

For instance, check if the \Doctrine\DBAL\Tools\Console\ConsoleRunner class exists. If it is, we're on DBAL <4.

Copy link
Member

Choose a reason for hiding this comment

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

You can check if the BigIntType has a getName() method. That should not be the case on DBAL 4.

Copy link
Contributor Author

@llupa llupa Apr 24, 2024

Choose a reason for hiding this comment

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

Ok, I actually even thought about having 2 extractors, one per DBAL major, and then in the compiler pass to set the respective class with the class exists check.

I will do classmethod exists as it is simple and straightforward, composer checks are fine, but, it implies composer is there to begin with 🤷

Copy link
Member

Choose a reason for hiding this comment

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

it implies composer is there to begin with 🤷

That does not sound like a strong requirement. 😄

That being said, on this repository, we rather do feature detection than relying on Composer's runtime API, so method_exists() is the way to go here.

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.

None yet

5 participants