-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix bigint PHP_INT_MIN/PHP_INT_MAX string to int convert #6410
Conversation
5b74171
to
dcbddf3
Compare
@derrabus can you please review? |
Please don't ping me on PRs please. |
I pinged you because of you authored the original PR, sorry. |
e22cc52
to
dc5cd73
Compare
347ded4
to
4c3258b
Compare
Please keep in mind that this piece of code will be executed on a hot path. If I hydrate thousands of entities with bigint fields, I don't want to execute |
PCRE JIT is very fast, but yes, the regex replace is possible to be coded /wo regex and I alredy considered that option because only limited number (4096) are cached. I will rework the code. |
70d3683
to
fc86908
Compare
done |
Sorry, but that implementation is way too complicated. I don't want to maintain this. |
The implementation is minimal, we strip leading plus sign, zeros and trailing zeros after decimal point. If the number is then castable into int without precision loss, we cast it. The leading/trailing zeros should be stripped because the input number can come from sources with explicit digits/decimal configured. This behaviour is tested and I do not think it can be implemented simpler. If you have an idea how to implemenet this simpler/better, I am of course ready for your ideas. |
If leading/trailing zeros should be supported, the impl. is minimal IMO. I would be happy if this can either be merged as is or please let me know how to fix the min/max issue differently. |
Which DBMS formats 2^31-1 with leading zeros? |
I tested all DBs using https://dbfiddle.uk/6OSky-ka and none DB vendor prepend leading zeros even for DECIMAL type by default. So you want me to remove the "leading zeros accepting" code in order to save a few lines of code? |
🤷♂️ |
@greg0ire with Alexander I got to a point when this PR is lighweight and passing the tests. Can you please clarify "I don't think this is going anywhere" into a feedback I can act on? Can you please reopen this PR? |
Clarification: I don't think there is anything you can do. |
Sorry, do you understand the problem, are you aware that valid max. int |
I don't understand the problem, and I do not see an explanation about it anywhere. |
The problem ist that if the DB would return PHP_INT_MAX as string, we would not convert it to int although one might expect that. |
I won't block this anymore but I don't get the fix, feel free to deal with this if you understand it @derrabus |
c05f798
to
82fdb8a
Compare
82fdb8a
to
366175c
Compare
366175c
to
e609cb7
Compare
As soon as the unnecessary changes to the test have been reverted, I'm fine with the PR. |
Summary
Resolve #6177 (comment) discussion and related original #6177.
Whole native php
int
range is guaranteed to be supported per https://www.doctrine-project.org/projects/doctrine-dbal/en/4.0/reference/types.html#bigint docs.