Commit 5a46f577 authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-756] Add new method AbstractPlatform#getVendor().

parent 2632d4a7
# Upgrade to 2.5 # Upgrade to 2.5
## New abstract method `getVendor` on `AbstractPlatform`
Because we have been getting more and more version specific platforms
it is necessary to detect platforms based on the vendor, not on their version names.
For this a new method `abstract public function getVendor()` was introduced on
the `AbstractPlatform`.
If you have a custom platform that extends from `AbstractPlatform` you need to provide
this method as of version 2.5 of DBAL.
## datetime Type uses date_create() as fallback ## datetime Type uses date_create() as fallback
Before 2.5 the DateTime type always required a specific format, defined in Before 2.5 the DateTime type always required a specific format, defined in
......
...@@ -337,6 +337,13 @@ abstract class AbstractPlatform ...@@ -337,6 +337,13 @@ abstract class AbstractPlatform
*/ */
abstract public function getName(); abstract public function getName();
/**
* Gets the name of the vendor, independent of version.
*
* @return string
*/
abstract public function getVendor();
/** /**
* Registers a doctrine type to be used in conjunction with a column type of this platform. * Registers a doctrine type to be used in conjunction with a column type of this platform.
* *
......
...@@ -107,6 +107,14 @@ class DB2Platform extends AbstractPlatform ...@@ -107,6 +107,14 @@ class DB2Platform extends AbstractPlatform
return 'db2'; return 'db2';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'db2';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -40,6 +40,14 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -40,6 +40,14 @@ class DrizzlePlatform extends AbstractPlatform
return 'drizzle'; return 'drizzle';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'drizzle';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -795,6 +795,14 @@ class MySqlPlatform extends AbstractPlatform ...@@ -795,6 +795,14 @@ class MySqlPlatform extends AbstractPlatform
return 'mysql'; return 'mysql';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'mysql';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -810,6 +810,14 @@ LEFT JOIN user_cons_columns r_cols ...@@ -810,6 +810,14 @@ LEFT JOIN user_cons_columns r_cols
return 'oracle'; return 'oracle';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'oracle';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -874,6 +874,14 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -874,6 +874,14 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'postgresql'; return 'postgresql';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'postgresql';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
......
...@@ -1005,6 +1005,14 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -1005,6 +1005,14 @@ class SQLAnywherePlatform extends AbstractPlatform
return 'sqlanywhere'; return 'sqlanywhere';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'sqlanywhere';
}
/** /**
* Obtain DBMS specific SQL code portion needed to set a primary key * Obtain DBMS specific SQL code portion needed to set a primary key
* declaration to be used in statements like ALTER TABLE. * declaration to be used in statements like ALTER TABLE.
......
...@@ -1286,6 +1286,14 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -1286,6 +1286,14 @@ class SQLServerPlatform extends AbstractPlatform
return 'mssql'; return 'mssql';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'sqlserver';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -486,6 +486,14 @@ class SqlitePlatform extends AbstractPlatform ...@@ -486,6 +486,14 @@ class SqlitePlatform extends AbstractPlatform
return 'sqlite'; return 'sqlite';
} }
/**
* {@inheritDoc}
*/
public function getVendor()
{
return 'sqlite';
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -56,6 +56,12 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -56,6 +56,12 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
return 'mock'; return 'mock';
} }
public function getVendor()
{
return 'mock';
}
protected function initializeDoctrineTypeMappings() { protected function initializeDoctrineTypeMappings() {
} }
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
......
...@@ -72,6 +72,10 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -72,6 +72,10 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
return 'mock'; return 'mock';
} }
public function getVendor()
{
return 'mock';
}
protected function initializeDoctrineTypeMappings() { protected function initializeDoctrineTypeMappings() {
} }
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
...@@ -85,4 +89,4 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -85,4 +89,4 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
throw DBALException::notSupported(__METHOD__); throw DBALException::notSupported(__METHOD__);
} }
} }
\ No newline at end of file
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