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

PR #49504 breaks database save when using certain numeric values with string fields. #49701

Closed
apreiml opened this issue Jan 16, 2024 · 1 comment · Fixed by #49702
Closed
Labels

Comments

@apreiml
Copy link
Contributor

apreiml commented Jan 16, 2024

Laravel Version

10.40.0

PHP Version

8.2

Database Driver & Version

No response

Description

#49504 breaks saving of string columns in certain cases.

As shown in the reproduction steps, sometimes string fields contain numbers that should not be parsed as decimals. I'd like to suggest to revert the pull request. I guess the dirty state issue in that pr could be solved using casts or mutators.

Steps To Reproduce

To trigger the bug store an integer in a string field of a model and use an invalid integer on the next save. E.g.

$address = new Address(['building' => '107']); // building is a varchar(255)
$address->save();

$address->building = '5 '; // note the whitespace 
$address->save();

will result in:

1) Tests\Import\Stories\AddressTest::testStrangeBuilding
Brick\Math\Exception\NumberFormatException: The given value "5 " does not represent a valid number.

/home/ape/s/ws/wasser_web/vendor/brick/math/src/BigNumber.php:69
/home/ape/s/ws/wasser_web/vendor/brick/math/src/BigNumber.php:76
/home/ape/s/ws/wasser_web/vendor/brick/math/src/BigDecimal.php:56
/home/ape/s/ws/wasser_web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:2104
@driesvints
Copy link
Member

Thanks for reporting!

cc @imahmood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants