Unverified Commit 03ccace5 authored by Sergei Morozov's avatar Sergei Morozov

Merge pull request #3211 from morozov/issues/3167

Removed support for DB-generated UUIDs
parents e6d452e0 d7f06f31
# Upgrade to 3.0
## BC BREAK: Removed support for DB-generated UUIDs
The support for DB-generated UUIDs was removed as non-portable.
Please generate UUIDs on the application side (e.g. using [ramsey/uuid](https://packagist.org/packages/ramsey/uuid)).
## BC BREAK: Removed MsSQLKeywords class
The `Doctrine\DBAL\Platforms\MsSQLKeywords` has been removed.
......
......@@ -616,20 +616,6 @@ abstract class AbstractPlatform
throw DBALException::notSupported(__METHOD__);
}
/**
* Returns the global unique identifier expression.
*
* @deprecated Use application-generated UUIDs instead
*
* @return string
*
* @throws DBALException If not supported on this platform.
*/
public function getGuidExpression()
{
throw DBALException::notSupported(__METHOD__);
}
/**
* Returns the SQL snippet to get the average value of a column.
*
......
......@@ -79,16 +79,6 @@ class MySqlPlatform extends AbstractPlatform
return 'RLIKE';
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'UUID()';
}
/**
* {@inheritDoc}
*/
......
......@@ -85,16 +85,6 @@ class OraclePlatform extends AbstractPlatform
return 'INSTR(' . $str . ', ' . $substr . ', ' . $startPos . ')';
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'SYS_GUID()';
}
/**
* {@inheritdoc}
*/
......
......@@ -1015,16 +1015,6 @@ SQL
return 'TIME(0) WITHOUT TIME ZONE';
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'UUID_GENERATE_V4()';
}
/**
* {@inheritDoc}
*/
......
......@@ -665,16 +665,6 @@ class SQLAnywherePlatform extends AbstractPlatform
return '';
}
/**
* {@inheritdoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'NEWID()';
}
/**
* {@inheritdoc}
*/
......
......@@ -1002,16 +1002,6 @@ SQL
return 'DROP VIEW ' . $name;
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'NEWID()';
}
/**
* {@inheritDoc}
*/
......
......@@ -40,19 +40,6 @@ class SqlitePlatform extends AbstractPlatform
return 'REGEXP';
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return "HEX(RANDOMBLOB(4)) || '-' || HEX(RANDOMBLOB(2)) || '-4' || "
. "SUBSTR(HEX(RANDOMBLOB(2)), 2) || '-' || "
. "SUBSTR('89AB', 1 + (ABS(RANDOM()) % 4), 1) || "
. "SUBSTR(HEX(RANDOMBLOB(2)), 2) || '-' || HEX(RANDOMBLOB(6))";
}
/**
* {@inheritDoc}
*/
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Ticket;
use Doctrine\Tests\DbalFunctionalTestCase;
use function in_array;
use function preg_match;
/**
* @group DBAL-421
*/
class DBAL421Test extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
$platform = $this->connection->getDatabasePlatform()->getName();
if (in_array($platform, ['mysql', 'sqlite'])) {
return;
}
$this->markTestSkipped('Currently restricted to MySQL and SQLite.');
}
public function testGuidShouldMatchPattern()
{
$guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn();
$pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i';
self::assertEquals(1, preg_match($pattern, $guid), 'GUID does not match pattern');
}
/**
* This test does (of course) not proof that all generated GUIDs are
* random, it should however provide some basic confidence.
*/
public function testGuidShouldBeRandom()
{
$statement = $this->connection->prepare($this->getSelectGuidSql());
$guids = [];
for ($i = 0; $i < 99; $i++) {
$statement->execute();
$guid = $statement->fetchColumn();
self::assertNotContains($guid, $guids, 'Duplicate GUID detected');
$guids[] = $guid;
}
$statement->closeCursor();
}
private function getSelectGuidSql()
{
return 'SELECT ' . $this->connection->getDatabasePlatform()->getGuidExpression();
}
}
......@@ -635,7 +635,6 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
self::assertEquals('Y-m-d H:i:s.u', $this->platform->getDateTimeFormatString());
self::assertEquals('H:i:s.u', $this->platform->getTimeFormatString());
self::assertEquals('', $this->platform->getForUpdateSQL());
self::assertEquals('NEWID()', $this->platform->getGuidExpression());
self::assertEquals('LOCATE(string_column, substring_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
self::assertEquals('LOCATE(string_column, substring_column, 1)', $this->platform->getLocateExpression('string_column', 'substring_column', 1));
self::assertEquals("HASH(column, 'MD5')", $this->platform->getMd5Expression('column'));
......
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