-
-
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
Cast BIGINT
values to int if possible
#6177
Conversation
65896da
to
62cecdb
Compare
Co-authored-by: cizordj <[email protected]>
62cecdb
to
c04c987
Compare
Nice to see this feature implemented 😄. |
I'm not a big fan of this change. This now means that bigint properties now need to be declared as |
No, you can declare them as |
Errr, what? Once we put a large enough integer value to the database, we need to declare |
Which is only possible if:
In both cases, you deliberately decided to deal with integers that are larger than what your PHP setup can handle, so the "added complexity" you're talking about is justified. And if that |
Alright, thank you, hopefully this can be accommodated for in phpstan-doctrine correctly :) |
@ondrejmirtes by default, BigInts are signed 8-byte numbers that work well with PHP's integer type. However, if you're hosting your project on a 32-bit system, the PHP integer range is smaller, and larger numbers need to be converted to strings to function properly. The same goes for unsigned integers, as their range exceeds what PHP can handle, leading to the need to cast them as strings due to memory limitations. If your database uses signed integers, sticking to the integer type in PHP is just fine. |
💯 I have full confidence in the abilities of the authors of said package. 🚀 |
Just one more question about this - if the mapped property contains a |
Sure. It should be the string representation of an integer, obviously. |
Thanks :) So |
<!-- Fill in the relevant information below to help triage your pull request. --> | Q | A |------------- | ----------- | Type | bug | Fixed issues | n/a #### 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.
Summary
BigIntType
casts values retrieved from the database to int if they're inside the integer range of PHP. Previously, those values were always cast to string.This PR continues the work done by @cizordj in #6143.