Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
c1ed9fe5
Unverified
Commit
c1ed9fe5
authored
Jul 03, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require $platform in AbstractSchemaManager::__construct()
parent
d47d1a4d
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
67 additions
and
35 deletions
+67
-35
UPGRADE.md
UPGRADE.md
+5
-0
Connection.php
src/Connection.php
+6
-1
Driver.php
src/Driver.php
+1
-1
AbstractDB2Driver.php
src/Driver/AbstractDB2Driver.php
+3
-2
AbstractMySQLDriver.php
src/Driver/AbstractMySQLDriver.php
+3
-2
AbstractOracleDriver.php
src/Driver/AbstractOracleDriver.php
+3
-2
AbstractPostgreSQLDriver.php
src/Driver/AbstractPostgreSQLDriver.php
+3
-2
AbstractSQLServerDriver.php
src/Driver/AbstractSQLServerDriver.php
+3
-2
AbstractSQLiteDriver.php
src/Driver/AbstractSQLiteDriver.php
+3
-2
AbstractSchemaManager.php
src/Schema/AbstractSchemaManager.php
+3
-6
AbstractDB2DriverTest.php
tests/Driver/AbstractDB2DriverTest.php
+4
-1
AbstractDriverTest.php
tests/Driver/AbstractDriverTest.php
+4
-1
AbstractMySQLDriverTest.php
tests/Driver/AbstractMySQLDriverTest.php
+4
-1
AbstractOracleDriverTest.php
tests/Driver/AbstractOracleDriverTest.php
+4
-1
AbstractPostgreSQLDriverTest.php
tests/Driver/AbstractPostgreSQLDriverTest.php
+4
-1
AbstractSQLServerDriverTest.php
tests/Driver/AbstractSQLServerDriverTest.php
+4
-1
AbstractSQLiteDriverTest.php
tests/Driver/AbstractSQLiteDriverTest.php
+4
-1
DB2SchemaManagerTest.php
tests/Schema/DB2SchemaManagerTest.php
+2
-2
MySqlSchemaManagerTest.php
tests/Schema/MySqlSchemaManagerTest.php
+2
-2
SqliteSchemaManagerTest.php
tests/Schema/SqliteSchemaManagerTest.php
+2
-4
No files found.
UPGRADE.md
View file @
c1ed9fe5
# Upgrade to 3.0
## BC BREAK: Changes schema manager instantiation.
1.
The
`$platform`
argument of all schema manager constructors is no longer optional.
2.
A new
`$platform`
argument has been added to the
`Driver::getSchemaManager()`
method.
## BC BREAK: Changes in driver classes
1.
All implementations of the
`Driver`
interface have been made final.
...
...
src/Connection.php
View file @
c1ed9fe5
...
...
@@ -1446,11 +1446,16 @@ class Connection implements DriverConnection
* database schema through the connection.
*
* @return AbstractSchemaManager
*
* @throws DBALException
*/
public
function
getSchemaManager
()
{
if
(
$this
->
_schemaManager
===
null
)
{
$this
->
_schemaManager
=
$this
->
_driver
->
getSchemaManager
(
$this
);
$this
->
_schemaManager
=
$this
->
_driver
->
getSchemaManager
(
$this
,
$this
->
getDatabasePlatform
()
);
}
return
$this
->
_schemaManager
;
...
...
src/Driver.php
View file @
c1ed9fe5
...
...
@@ -39,7 +39,7 @@ interface Driver
*
* @return AbstractSchemaManager
*/
public
function
getSchemaManager
(
Connection
$conn
);
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
);
/**
* Gets the ExceptionConverter that can be used to convert driver-level exceptions into DBAL exceptions.
...
...
src/Driver/AbstractDB2Driver.php
View file @
c1ed9fe5
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
as
ExceptionConverterInterface
;
use
Doctrine\DBAL\Driver\API\IBMDB2\ExceptionConverter
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\DB2Platform
;
use
Doctrine\DBAL\Schema\DB2SchemaManager
;
...
...
@@ -25,9 +26,9 @@ abstract class AbstractDB2Driver implements Driver
/**
* {@inheritdoc}
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
DB2SchemaManager
(
$conn
);
return
new
DB2SchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverterInterface
...
...
src/Driver/AbstractMySQLDriver.php
View file @
c1ed9fe5
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
;
use
Doctrine\DBAL\Driver\API\MySQL
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\MariaDb1027Platform
;
use
Doctrine\DBAL\Platforms\MySQL57Platform
;
use
Doctrine\DBAL\Platforms\MySQL80Platform
;
...
...
@@ -123,9 +124,9 @@ abstract class AbstractMySQLDriver implements VersionAwarePlatformDriver
*
* @return MySqlSchemaManager
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
MySqlSchemaManager
(
$conn
);
return
new
MySqlSchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverter
...
...
src/Driver/AbstractOracleDriver.php
View file @
c1ed9fe5
...
...
@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver;
use
Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
;
use
Doctrine\DBAL\Driver\API\OCI
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Schema\OracleSchemaManager
;
...
...
@@ -26,9 +27,9 @@ abstract class AbstractOracleDriver implements Driver
/**
* {@inheritdoc}
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
OracleSchemaManager
(
$conn
);
return
new
OracleSchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverter
...
...
src/Driver/AbstractPostgreSQLDriver.php
View file @
c1ed9fe5
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
;
use
Doctrine\DBAL\Driver\API\PostgreSQL
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\PostgreSQL100Platform
;
use
Doctrine\DBAL\Platforms\PostgreSQL94Platform
;
use
Doctrine\DBAL\Schema\PostgreSqlSchemaManager
;
...
...
@@ -54,9 +55,9 @@ abstract class AbstractPostgreSQLDriver implements VersionAwarePlatformDriver
/**
* {@inheritdoc}
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
PostgreSqlSchemaManager
(
$conn
);
return
new
PostgreSqlSchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverter
...
...
src/Driver/AbstractSQLServerDriver.php
View file @
c1ed9fe5
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
as
ExceptionConverterInterface
;
use
Doctrine\DBAL\Driver\API\SQLSrv\ExceptionConverter
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\SQLServer2012Platform
;
use
Doctrine\DBAL\Schema\SQLServerSchemaManager
;
...
...
@@ -25,9 +26,9 @@ abstract class AbstractSQLServerDriver implements Driver
/**
* {@inheritdoc}
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
SQLServerSchemaManager
(
$conn
);
return
new
SQLServerSchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverterInterface
...
...
src/Driver/AbstractSQLiteDriver.php
View file @
c1ed9fe5
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
;
use
Doctrine\DBAL\Driver\API\SQLite
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Schema\SqliteSchemaManager
;
...
...
@@ -25,9 +26,9 @@ abstract class AbstractSQLiteDriver implements Driver
/**
* {@inheritdoc}
*/
public
function
getSchemaManager
(
Connection
$conn
)
public
function
getSchemaManager
(
Connection
$conn
,
AbstractPlatform
$platform
)
{
return
new
SqliteSchemaManager
(
$conn
);
return
new
SqliteSchemaManager
(
$conn
,
$platform
);
}
public
function
getExceptionConverter
()
:
ExceptionConverter
...
...
src/Schema/AbstractSchemaManager.php
View file @
c1ed9fe5
...
...
@@ -44,13 +44,10 @@ abstract class AbstractSchemaManager
*/
protected
$_platform
;
/**
* Constructor. Accepts the Connection instance to manage the schema for.
*/
public
function
__construct
(
Connection
$conn
,
?
AbstractPlatform
$platform
=
null
)
public
function
__construct
(
Connection
$connection
,
AbstractPlatform
$platform
)
{
$this
->
_conn
=
$conn
;
$this
->
_platform
=
$platform
??
$this
->
_conn
->
getDatabasePlatform
()
;
$this
->
_conn
=
$conn
ection
;
$this
->
_platform
=
$platform
;
}
/**
...
...
tests/Driver/AbstractDB2DriverTest.php
View file @
c1ed9fe5
...
...
@@ -26,7 +26,10 @@ class AbstractDB2DriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
DB2SchemaManager
(
$connection
);
return
new
DB2SchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverterInterface
...
...
tests/Driver/AbstractDriverTest.php
View file @
c1ed9fe5
...
...
@@ -83,7 +83,10 @@ abstract class AbstractDriverTest extends TestCase
public
function
testReturnsSchemaManager
()
:
void
{
$connection
=
$this
->
getConnectionMock
();
$schemaManager
=
$this
->
driver
->
getSchemaManager
(
$connection
);
$schemaManager
=
$this
->
driver
->
getSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
self
::
assertEquals
(
$this
->
createSchemaManager
(
$connection
),
$schemaManager
);
...
...
tests/Driver/AbstractMySQLDriverTest.php
View file @
c1ed9fe5
...
...
@@ -29,7 +29,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
MySqlSchemaManager
(
$connection
);
return
new
MySqlSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
...
...
tests/Driver/AbstractOracleDriverTest.php
View file @
c1ed9fe5
...
...
@@ -26,7 +26,10 @@ class AbstractOracleDriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
OracleSchemaManager
(
$connection
);
return
new
OracleSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
...
...
tests/Driver/AbstractPostgreSQLDriverTest.php
View file @
c1ed9fe5
...
...
@@ -27,7 +27,10 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
PostgreSqlSchemaManager
(
$connection
);
return
new
PostgreSqlSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
...
...
tests/Driver/AbstractSQLServerDriverTest.php
View file @
c1ed9fe5
...
...
@@ -20,7 +20,10 @@ abstract class AbstractSQLServerDriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
SQLServerSchemaManager
(
$connection
);
return
new
SQLServerSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverterInterface
...
...
tests/Driver/AbstractSQLiteDriverTest.php
View file @
c1ed9fe5
...
...
@@ -26,7 +26,10 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
{
return
new
SqliteSchemaManager
(
$connection
);
return
new
SqliteSchemaManager
(
$connection
,
$this
->
createPlatform
()
);
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
...
...
tests/Schema/DB2SchemaManagerTest.php
View file @
c1ed9fe5
...
...
@@ -33,9 +33,9 @@ final class DB2SchemaManagerTest extends TestCase
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
onlyMethods
([
'fetchAllAssociative'
,
'quote'
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
setConstructorArgs
([[],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
getMock
();
$this
->
manager
=
new
DB2SchemaManager
(
$this
->
conn
);
$this
->
manager
=
new
DB2SchemaManager
(
$this
->
conn
,
$platform
);
}
/**
...
...
tests/Schema/MySqlSchemaManagerTest.php
View file @
c1ed9fe5
...
...
@@ -34,9 +34,9 @@ class MySqlSchemaManagerTest extends TestCase
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
onlyMethods
([
'fetchAllAssociative'
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
setConstructorArgs
([[],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
getMock
();
$this
->
manager
=
new
MySqlSchemaManager
(
$this
->
conn
);
$this
->
manager
=
new
MySqlSchemaManager
(
$this
->
conn
,
$platform
);
}
public
function
testCompositeForeignKeys
()
:
void
...
...
tests/Schema/SqliteSchemaManagerTest.php
View file @
c1ed9fe5
...
...
@@ -17,9 +17,8 @@ class SqliteSchemaManagerTest extends TestCase
public
function
testParseColumnCollation
(
?
string
$collation
,
string
$column
,
string
$sql
)
:
void
{
$conn
=
$this
->
createMock
(
Connection
::
class
);
$conn
->
method
(
'getDatabasePlatform'
)
->
willReturn
(
new
SqlitePlatform
());
$manager
=
new
SqliteSchemaManager
(
$conn
);
$manager
=
new
SqliteSchemaManager
(
$conn
,
new
SqlitePlatform
()
);
$ref
=
new
ReflectionMethod
(
$manager
,
'parseColumnCollationFromSQL'
);
$ref
->
setAccessible
(
true
);
...
...
@@ -58,9 +57,8 @@ class SqliteSchemaManagerTest extends TestCase
public
function
testParseColumnCommentFromSQL
(
?
string
$comment
,
string
$column
,
string
$sql
)
:
void
{
$conn
=
$this
->
createMock
(
Connection
::
class
);
$conn
->
method
(
'getDatabasePlatform'
)
->
willReturn
(
new
SqlitePlatform
());
$manager
=
new
SqliteSchemaManager
(
$conn
);
$manager
=
new
SqliteSchemaManager
(
$conn
,
new
SqlitePlatform
()
);
$ref
=
new
ReflectionMethod
(
$manager
,
'parseColumnCommentFromSQL'
);
$ref
->
setAccessible
(
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment