Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Revert "[6.x] Wrap MySQL default values in parentheses" #29943

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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