-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Labels
Description
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