Skip to content

Commit

Permalink
Fix storedAs virtualAs
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandobandeira committed Dec 6, 2016
1 parent 2354db8 commit d41b2ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ protected function modifyCollate(Blueprint $blueprint, Fluent $column)
*/
protected function modifyNullable(Blueprint $blueprint, Fluent $column)
{
return $column->nullable ? ' null' : ' not null';
if (is_null($column->virtualAs) && is_null($column->storedAs)) {
return $column->nullable ? ' null' : ' not null';
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function testAddingGeneratedColumn()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertEquals(1, count($statements));
$this->assertEquals('alter table `products` add `price` int not null, add `discounted_virtual` int as (price - 5) not null, add `discounted_stored` int as (price - 5) stored not null', $statements[0]);
$this->assertEquals('alter table `products` add `price` int not null, add `discounted_virtual` int as (price - 5), add `discounted_stored` int as (price - 5) stored', $statements[0]);
}

public function testAddingString()
Expand Down

0 comments on commit d41b2ea

Please sign in to comment.