[Fixed] Laravel: Decimal Attribute Casting

0 votes
asked Mar 16, 2019 in Solved by Andman (180 points)
recategorized Mar 18, 2019 by ludek.vodicka

Skipper Beta: 3.2.17.1516

I was experiencing an irritating error after I imported my project from MariaDB using the Laravel external import tool.

Laravel Error:
"message": "Undefined offset: 1",
"exception": "ErrorException",
"file": "/var/www/projectname/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php",

Solution:
After a lot of experimenting and reading Laravel documentation, I found out that the bug came from decimals and attribute casting.

"When casting to decimal, you should define the number of digits, eg. decimal:2"
https://laravel.com/docs/5.8/eloquent-mutators#attribute-casting

The import failed to grab the decimal arguments. If it not possible to grab them, it should default to some other value.

After manually setting the decimal digits the export to Laravel worked perfectly.

commented Mar 16, 2019 by ludek.vodicka Skipper developer (140,450 points)

Thanks for the info.

Decimal size should be imported correctly, but we tested that only via MySQL. It's possible that MariaDB is returning this param in a slightly different way and because of that it's wrongly imported

Can I ask you for one example SQL DDL of the wrongly imported table? (CREATE TABLE .... command)?

We will try it directly on MariaDB engine.

Thanks

1 Answer

+1 vote
answered Mar 18, 2019 by ludek.vodicka Skipper developer (140,450 points)
selected Mar 18, 2019 by Andman
 
Best answer

We just found the issue.

"scale" parameter was wronlgy imported to "scale" instead of "decimal" for Laravel frameworks.

This issue is now fixed in latest beta: https://support.skipper18.com/402/downloads-skipper-beta

Thank you for reporting this issue.

commented Mar 18, 2019 by Andman (180 points)

Great to hear!

...