Skip to content

Commit

Permalink
Revert "wrap MySQL default values in parentheses (#29878)" (#29943)
Browse files Browse the repository at this point in the history
This reverts commit 2f20d88.
  • Loading branch information
driesvints authored and taylorotwell committed Sep 10, 2019
1 parent d75aed7 commit b18be76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ protected function modifyNullable(Blueprint $blueprint, Fluent $column)
protected function modifyDefault(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->default)) {
return ' default ('.$this->getDefaultValue($column->default).')';
return ' default '.$this->getDefaultValue($column->default);
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ public function testAddingString()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table `users` add `foo` varchar(100) null default (\'bar\')', $statements[0]);
$this->assertSame('alter table `users` add `foo` varchar(100) null default \'bar\'', $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default(new Expression('CURRENT TIMESTAMP'));
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table `users` add `foo` varchar(100) null default (CURRENT TIMESTAMP)', $statements[0]);
$this->assertSame('alter table `users` add `foo` varchar(100) null default CURRENT TIMESTAMP', $statements[0]);
}

public function testAddingText()
Expand Down Expand Up @@ -771,7 +771,7 @@ public function testAddingTimestampWithDefault()
$blueprint->timestamp('created_at')->default('2015-07-22 11:43:17');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertSame("alter table `users` add `created_at` timestamp not null default ('2015-07-22 11:43:17')", $statements[0]);
$this->assertSame("alter table `users` add `created_at` timestamp not null default '2015-07-22 11:43:17'", $statements[0]);
}

public function testAddingTimestampTz()
Expand All @@ -798,7 +798,7 @@ public function testAddingTimeStampTzWithDefault()
$blueprint->timestampTz('created_at')->default('2015-07-22 11:43:17');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertSame("alter table `users` add `created_at` timestamp not null default ('2015-07-22 11:43:17')", $statements[0]);
$this->assertSame("alter table `users` add `created_at` timestamp not null default '2015-07-22 11:43:17'", $statements[0]);
}

public function testAddingTimestamps()
Expand Down

0 comments on commit b18be76

Please sign in to comment.