Skip to content

Commit

Permalink
Merge pull request #16683 from fernandobandeira/5.3
Browse files Browse the repository at this point in the history
[5.3] Fix storedAs virtualAs
  • Loading branch information
taylorotwell committed Dec 7, 2016
2 parents eae767c + d41b2ea commit 23f5a4c
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 23f5a4c

Please sign in to comment.