Laravel-4-Generators icon indicating copy to clipboard operation
Laravel-4-Generators copied to clipboard

Having spaces after the comma in "decimal(X, Y)" fields generates nonsense

Open dequis opened this issue 11 years ago • 5 comments

(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 avatar Mar 13 '14 15:03 dequis

@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(); });

ghost avatar Mar 13 '14 15:03 ghost

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.

dequis avatar Mar 13 '14 15:03 dequis

Yeah, it's the added space. I know that sucks, but it's hard to parse the fields otherwise.

laracasts avatar Mar 13 '14 15:03 laracasts

At least it could detect that the parsed input doesn't make sense, and warn about it. Or document usage of decimal fields.

dequis avatar Mar 13 '14 16:03 dequis

(Just realized I can change the ticket subject myself)

dequis avatar Mar 13 '14 16:03 dequis