From 931d167e057d3215b0fd5bb9358625db5bc38894 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 10 Sep 2019 20:44:45 +0200 Subject: [PATCH] Revert "wrap MySQL default values in parentheses (#29878)" This reverts commit 2f20d8875f0473d10e15e82a11a71c92a4c59864. --- src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | 2 +- tests/Database/DatabaseMySqlSchemaGrammarTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 47f3170ade01..87a3ef7fcd75 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -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); } } diff --git a/tests/Database/DatabaseMySqlSchemaGrammarTest.php b/tests/Database/DatabaseMySqlSchemaGrammarTest.php index b16a0cbf65fb..9d405c81c606 100755 --- a/tests/Database/DatabaseMySqlSchemaGrammarTest.php +++ b/tests/Database/DatabaseMySqlSchemaGrammarTest.php @@ -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() @@ -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() @@ -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()