Laravel-4-Generators
Laravel-4-Generators copied to clipboard
Having spaces after the comma in "decimal(X, Y)" fields generates nonsense
(previous subject: Decimal fields with precision not supported by --fields)
I created a migration with this fields parameter:
--fields="somevalue:decimal(8, 2)"
And it got translated to this:
$table->decimal(8('somevalue');
$table->('2)');
I'm not sure what happened here.
There have been a few pull requests (#105, #104, #72) adding this feature before (for generators 1.x), but all of them are closed, and since we're in 2.x already and it still doesn't work, I figured I should open a ticket.
@dequis its the space issue in your code between , and 2 you have one space --fields="somevalue:decimal(8, 2)" it must be like this --fields="somevalue:decimal(8,2)" I test it and
php artisan generate:migration create_test_table --fields="title:decimal(8,2)"
GENERATES Schema::create('test', function(Blueprint $table) { $table->increments('id'); $table->decimal('title', 8,2); $table->timestamps(); });
And
php artisan generate:migration create_test_table --fields="title:decimal(8, 2)"
GENERATES
Schema::create('test', function(Blueprint $table) { $table->increments('id'); $table->decimal(8('title'); $table->('2)'); $table->timestamps(); });
Oh, sweet, thanks for pointing that out!. I guess the subject of the issue should be changed then, since the real issue is that having spaces there breaks it.
Yeah, it's the added space. I know that sucks, but it's hard to parse the fields otherwise.
At least it could detect that the parsed input doesn't make sense, and warn about it. Or document usage of decimal fields.
(Just realized I can change the ticket subject myself)