Commit d68603c4 authored by Steve Müller's avatar Steve Müller

add automatic platform version detection for PostgreSQL 9.1

parent f43bebc7
......@@ -22,6 +22,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
......@@ -98,11 +99,14 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
$patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
if (version_compare($version, '9.2', '>=')) {
return new PostgreSQL92Platform();
switch(true) {
case version_compare($version, '9.2', '>='):
return new PostgreSQL92Platform();
case version_compare($version, '9.1', '>='):
return new PostgreSQL91Platform();
default:
return new PostgreSqlPlatform();
}
return $this->getDatabasePlatform();
}
/**
......
......@@ -55,7 +55,11 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions()
{
return array(
array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'),
array('9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'),
array('9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
array('9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
array('9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
array('9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
array('9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
array('9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
......
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