Unverified Commit 345b650b authored by belgattitude's avatar belgattitude Committed by Luís Cobucci

Removes mariadb supports for TEXT/BLOB default values

parent 9ca9589d
......@@ -66,15 +66,4 @@ final class MariaDb1027Platform extends MySqlPlatform
$this->doctrineTypeMapping['json'] = Type::JSON;
}
/**
* @inheritdoc
*
* Since MariaDB 10.2.1 blob and text columns can have a default value.
* @link https://mariadb.com/kb/en/library/blob-and-text-data-types/
*/
protected function isDefaultValueSupportedForType(Type $field) : bool
{
return true;
}
}
......@@ -582,7 +582,7 @@ class MySqlPlatform extends AbstractPlatform
// Don't propagate default value changes for unsupported column types.
if ($columnDiff->hasChanged('default') &&
count($columnDiff->changedProperties) === 1 &&
! $this->isDefaultValueSupportedForType($columnArray['type'])
($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType)
) {
continue;
}
......
......@@ -446,38 +446,4 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diff = $comparator->diffTable($table, $onlineTable);
self::assertFalse($diff, "Tables should be identical with column defauts time and date.");
}
/**
* Since MariaDB 10.2.1, Blob and text columns can have a default value
*
* @link https://mariadb.com/kb/en/library/blob-and-text-data-types
*/
public function testDoesPropagateDefaultValuesForBlobTextAndJson() : void
{
if (!$this->_sm->getDatabasePlatform() instanceof MariaDb1027Platform) {
$this->markTestSkipped('Only relevant for MariaDb102Platform.');
}
$table = new Table("text_blob_default_value");
$json = json_encode(['prop1' => "Hello", 'prop2' => 10]);
$table->addColumn('def_text', 'text', ['default' => "Hello"]);
$table->addColumn('def_text_null', 'text', ['notnull' => false, 'default' => 'def']);
$table->addColumn('def_blob', 'blob', ['default' => 'World']);
$table->addColumn('def_json', 'json', ['default' => $json]);
$this->_sm->dropAndCreateTable($table);
$onlineTable = $this->_sm->listTableDetails("text_blob_default_value");
self::assertSame("Hello", $onlineTable->getColumn('def_text')->getDefault());
self::assertSame('def', $onlineTable->getColumn('def_text_null')->getDefault());
self::assertSame('World', $onlineTable->getColumn('def_blob')->getDefault());
self::assertSame($json, $onlineTable->getColumn('def_json')->getDefault());
$comparator = new Comparator();
self::assertFalse($comparator->diffTable($table, $onlineTable));
}
}
......@@ -47,53 +47,4 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
{
$this->markTestSkipped('MariaDB102Platform support propagation of default values for BLOB and TEXT columns');
}
/**
* Since MariaDB 10.2, Text and Blob can have a default value.
*/
public function testPropagateDefaultValuesForTextAndBlobColumnTypes() : void
{
$table = new Table("text_blob_default_value");
$table->addColumn('def_text', Type::TEXT, ['default' => "hello"]);
$table->addColumn('def_blob', Type::BLOB, ['default' => 'world']);
self::assertSame(
["CREATE TABLE text_blob_default_value (def_text LONGTEXT DEFAULT 'hello' NOT NULL, def_blob LONGBLOB DEFAULT 'world' NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"],
$this->_platform->getCreateTableSQL($table)
);
$diffTable = clone $table;
$diffTable->changeColumn('def_text', ['default' => "hello"]);
$diffTable->changeColumn('def_blob', ['default' => 'world']);
$comparator = new Comparator();
self::assertFalse($comparator->diffTable($table, $diffTable));
}
public function testPropagateDefaultValuesForJsonColumnType() : void
{
$table = new Table("text_json_default_value");
$json = json_encode(['prop1' => "Hello", 'prop2' => 10]);
$table->addColumn('def_json', Type::TEXT, ['default' => $json]);
$jsonType = $this->createPlatform()->getJsonTypeDeclarationSQL($table->getColumn('def_json')->toArray());
self::assertSame(
["CREATE TABLE text_json_default_value (def_json $jsonType DEFAULT '{\"prop1\":\"Hello\",\"prop2\":10}' NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"],
$this->_platform->getCreateTableSQL($table)
);
$diffTable = clone $table;
$diffTable->changeColumn('def_json', ['default' => $json]);
$comparator = new Comparator();
self::assertFalse($comparator->diffTable($table, $diffTable));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment