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
f198104c
Unverified
Commit
f198104c
authored
Jun 09, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecated platform-specific portability mode constants
parent
7047798f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
19 deletions
+94
-19
UPGRADE.md
UPGRADE.md
+5
-0
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+9
-19
OptimizeFlags.php
lib/Doctrine/DBAL/Portability/OptimizeFlags.php
+44
-0
OptimizeFlagsTest.php
tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php
+36
-0
No files found.
UPGRADE.md
View file @
f198104c
# Upgrade to 2.11
# Upgrade to 2.11
## Deprecated `Portability\Connection::PORTABILITY_{PLATFORM}` constants`
The platform-specific portability mode flags are meant to be used only by the portability layer internally to optimize
the user-provided mode for the current database platform.
## Deprecated `MasterSlaveConnection` use `PrimaryReadReplicaConnection`
## Deprecated `MasterSlaveConnection` use `PrimaryReadReplicaConnection`
The
`Doctrine\DBAL\Connections\MasterSlaveConnection`
class is renamed to
`Doctrine\DBAL\Connections\PrimaryReadReplicaConnection`
.
The
`Doctrine\DBAL\Connections\MasterSlaveConnection`
class is renamed to
`Doctrine\DBAL\Connections\PrimaryReadReplicaConnection`
.
...
...
lib/Doctrine/DBAL/Portability/Connection.php
View file @
f198104c
...
@@ -23,6 +23,10 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -23,6 +23,10 @@ class Connection extends \Doctrine\DBAL\Connection
public
const
PORTABILITY_EMPTY_TO_NULL
=
4
;
public
const
PORTABILITY_EMPTY_TO_NULL
=
4
;
public
const
PORTABILITY_FIX_CASE
=
8
;
public
const
PORTABILITY_FIX_CASE
=
8
;
/**#@+
*
* @deprecated Will be removed as internal implementation details.
*/
public
const
PORTABILITY_DB2
=
13
;
public
const
PORTABILITY_DB2
=
13
;
public
const
PORTABILITY_ORACLE
=
9
;
public
const
PORTABILITY_ORACLE
=
9
;
public
const
PORTABILITY_POSTGRESQL
=
13
;
public
const
PORTABILITY_POSTGRESQL
=
13
;
...
@@ -31,6 +35,7 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -31,6 +35,7 @@ class Connection extends \Doctrine\DBAL\Connection
public
const
PORTABILITY_DRIZZLE
=
13
;
public
const
PORTABILITY_DRIZZLE
=
13
;
public
const
PORTABILITY_SQLANYWHERE
=
13
;
public
const
PORTABILITY_SQLANYWHERE
=
13
;
public
const
PORTABILITY_SQLSRV
=
13
;
public
const
PORTABILITY_SQLSRV
=
13
;
/**#@-*/
/** @var int */
/** @var int */
private
$portability
=
self
::
PORTABILITY_NONE
;
private
$portability
=
self
::
PORTABILITY_NONE
;
...
@@ -47,25 +52,10 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -47,25 +52,10 @@ class Connection extends \Doctrine\DBAL\Connection
if
(
$ret
)
{
if
(
$ret
)
{
$params
=
$this
->
getParams
();
$params
=
$this
->
getParams
();
if
(
isset
(
$params
[
'portability'
]))
{
if
(
isset
(
$params
[
'portability'
]))
{
if
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'oracle'
)
{
$this
->
portability
=
$params
[
'portability'
]
=
(
new
OptimizeFlags
())(
$params
[
'portability'
]
&=
self
::
PORTABILITY_ORACLE
;
$this
->
getDatabasePlatform
(),
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'postgresql'
)
{
$params
[
'portability'
]
$params
[
'portability'
]
&=
self
::
PORTABILITY_POSTGRESQL
;
);
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'sqlite'
)
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_SQLITE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'drizzle'
)
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_DRIZZLE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'sqlanywhere'
)
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_SQLANYWHERE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'db2'
)
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_DB2
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'mssql'
)
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_SQLSRV
;
}
else
{
$params
[
'portability'
]
&=
self
::
PORTABILITY_OTHERVENDORS
;
}
$this
->
portability
=
$params
[
'portability'
];
}
}
if
(
isset
(
$params
[
'fetch_case'
])
&&
$this
->
portability
&
self
::
PORTABILITY_FIX_CASE
)
{
if
(
isset
(
$params
[
'fetch_case'
])
&&
$this
->
portability
&
self
::
PORTABILITY_FIX_CASE
)
{
...
...
lib/Doctrine/DBAL/Portability/OptimizeFlags.php
0 → 100644
View file @
f198104c
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Portability
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\DB2Platform
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Platforms\PostgreSQL94Platform
;
use
Doctrine\DBAL\Platforms\SQLAnywhere16Platform
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Platforms\SQLServer2012Platform
;
final
class
OptimizeFlags
{
/**
* Platform-specific portability flags that need to be excluded from the user-provided mode
* since the platform already operates in this mode to avoid unnecessary conversion overhead.
*
* @var array<string,int>
*/
private
static
$platforms
=
[
DB2Platform
::
class
=>
0
,
OraclePlatform
::
class
=>
Connection
::
PORTABILITY_EMPTY_TO_NULL
,
PostgreSQL94Platform
::
class
=>
0
,
SQLAnywhere16Platform
::
class
=>
0
,
SqlitePlatform
::
class
=>
0
,
SQLServer2012Platform
::
class
=>
0
,
];
public
function
__invoke
(
AbstractPlatform
$platform
,
int
$flags
)
:
int
{
foreach
(
self
::
$platforms
as
$class
=>
$mask
)
{
if
(
$platform
instanceof
$class
)
{
$flags
&=
~
$mask
;
break
;
}
}
return
$flags
;
}
}
tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php
0 → 100644
View file @
f198104c
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Portability
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Portability\Connection
;
use
Doctrine\DBAL\Portability\OptimizeFlags
;
use
PHPUnit\Framework\TestCase
;
class
OptimizeFlagsTest
extends
TestCase
{
/** @var OptimizeFlags */
private
$optimizeFlags
;
protected
function
setUp
()
:
void
{
$this
->
optimizeFlags
=
new
OptimizeFlags
();
}
public
function
testOracle
()
:
void
{
$flags
=
(
$this
->
optimizeFlags
)(
new
OraclePlatform
(),
Connection
::
PORTABILITY_ALL
);
self
::
assertSame
(
0
,
$flags
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
);
}
public
function
testAnotherPlatform
()
:
void
{
$flags
=
(
$this
->
optimizeFlags
)(
new
SqlitePlatform
(),
Connection
::
PORTABILITY_ALL
);
self
::
assertSame
(
Connection
::
PORTABILITY_ALL
,
$flags
);
}
}
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