Skip to content

Commit

Permalink
t push origin masterMerge branch 'Niban-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Feb 28, 2015
2 parents 582022b + b5dc81f commit 20ba013
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
16 changes: 16 additions & 0 deletions spec/Migrations/SchemaParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ function it_parses_correctly_when_the_type_contains_method_arguments()
['name' => 'amount', 'type' => 'decimal', 'arguments' => ['5', '2'], 'options' => []]
]);
}

function it_parses_schema_with_multiple_fields_using_no_spaces()
{
$this->parse('name:string,age:integer')->shouldReturn([
['name' => 'name', 'type' => 'string', 'arguments' => [], 'options' => []],
['name' => 'age', 'type' => 'integer', 'arguments' => [], 'options' => []],
]);
}

function it_parses_schema_with_multiple_fields_containing_arguments_using_no_spaces()
{
$this->parse('name:string,amount:decimal(5,2)')->shouldReturn([
['name' => 'name', 'type' => 'string', 'arguments' => [], 'options' => []],
['name' => 'amount', 'type' => 'decimal', 'arguments' => ['5', '2'], 'options' => []]
]);
}
}
2 changes: 1 addition & 1 deletion src/Commands/PivotMigrationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PivotMigrationMakeCommand extends GeneratorCommand
*
* @var string
*/
protected $description = 'Create a new migration pivot class.';
protected $description = 'Create a new migration pivot class';

/**
* The type of class being generated.
Expand Down
4 changes: 3 additions & 1 deletion src/Migrations/SchemaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function parse($schema)
*/
private function getFields($schema)
{
return preg_split('/\s?,\s/', $schema);
$preg_split = preg_split('/,(?![^()]*+\\))/', $schema);

return array_map("trim", $preg_split);
}

/**
Expand Down

0 comments on commit 20ba013

Please sign in to comment.