You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a resource file from the db with a bigint key, the data type is mistakenly set to string and incrementing is set to false in the model.
#214
This is a wonderful package and I've used it with several projects over the years (Many Thanks!), but have been modifying created models to correct this issue for a while, and I wanted to try to resolve this issue...
Environment:
Laravel-Code-Generator Version: 3.0.2
Laravel Version: 11.36.1
Description:
If my PK is a bigint, the data type gets set to string as the ParserBase::getHtmlType also uses the eloquent_type_to_html_type map, but there's not a key 'bigInteger' with a capital I, so it defaults to string. What we end up with in the model is this:
When, ideally, no code would get added to the model as the default for PrimaryKey is id.
If I add a line to the map that accounts for this key like so 'bigInteger' => 'bigInteger', it works correctly, but I don't know if that is ideal as a fix. It seems there could be other issues with case sensitivity as you have other values in this map that are mixed case. Not sure if a strtolower on the key before the lookup in getHtmlType is optimal in all cases...?
Steps/Commands To Reproduce:
Run php artisan resource-file:from-database modelname on a database table with a bigint primary key.
@tcowin thanks for using this package and reporting this issue.
I don't think I have anytime soon to debug this. But you maybe able to test it out if you feel like it. You may be able to fix it and submit a PR for this.
This is a wonderful package and I've used it with several projects over the years (Many Thanks!), but have been modifying created models to correct this issue for a while, and I wanted to try to resolve this issue...
Environment:
Description:
If my PK is a bigint, the data type gets set to string as the ParserBase::getHtmlType also uses the eloquent_type_to_html_type map, but there's not a key 'bigInteger' with a capital I, so it defaults to string. What we end up with in the model is this:
When, ideally, no code would get added to the model as the default for PrimaryKey is id.
If I add a line to the map that accounts for this key like so 'bigInteger' => 'bigInteger', it works correctly, but I don't know if that is ideal as a fix. It seems there could be other issues with case sensitivity as you have other values in this map that are mixed case. Not sure if a strtolower on the key before the lookup in getHtmlType is optimal in all cases...?
Steps/Commands To Reproduce:
Run php artisan resource-file:from-database modelname on a database table with a bigint primary key.
Content Of The Resource-File:
The text was updated successfully, but these errors were encountered: