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
9e2a9a40
Unverified
Commit
9e2a9a40
authored
May 29, 2019
by
Jonathan H. Wage
Committed by
Sergei Morozov
Nov 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add proper types to the Doctrine\DBAL\Sharding namespace.
parent
f90c5001
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
63 deletions
+30
-63
PoolingShardManager.php
lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
+5
-5
SQLAzureFederationsSynchronizer.php
...BAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
+5
-15
SQLAzureShardManager.php
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
+11
-23
MultiTenantVisitor.php
...rine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
+3
-9
ShardManager.php
lib/Doctrine/DBAL/Sharding/ShardManager.php
+6
-11
No files found.
lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
View file @
9e2a9a40
...
...
@@ -18,7 +18,7 @@ class PoolingShardManager implements ShardManager
/** @var ShardChoser */
private
$choser
;
/** @var
string|null
*/
/** @var
mixed
*/
private
$currentDistributionValue
;
public
function
__construct
(
PoolingShardConnection
$conn
)
...
...
@@ -31,7 +31,7 @@ class PoolingShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
selectGlobal
()
public
function
selectGlobal
()
:
void
{
$this
->
conn
->
connect
(
0
);
$this
->
currentDistributionValue
=
null
;
...
...
@@ -40,7 +40,7 @@ class PoolingShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
selectShard
(
$distributionValue
)
public
function
selectShard
(
$distributionValue
)
:
void
{
$shardId
=
$this
->
choser
->
pickShard
(
$distributionValue
,
$this
->
conn
);
$this
->
conn
->
connect
(
$shardId
);
...
...
@@ -58,7 +58,7 @@ class PoolingShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
getShards
()
public
function
getShards
()
:
array
{
$params
=
$this
->
conn
->
getParams
();
$shards
=
[];
...
...
@@ -75,7 +75,7 @@ class PoolingShardManager implements ShardManager
*
* @throws RuntimeException
*/
public
function
queryAll
(
$sql
,
array
$params
,
array
$types
)
public
function
queryAll
(
string
$sql
,
array
$params
,
array
$types
)
:
array
{
$shards
=
$this
->
getShards
();
if
(
!
$shards
)
{
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
View file @
9e2a9a40
...
...
@@ -158,7 +158,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/**
* @return Schema[]
*/
private
function
partitionSchema
(
Schema
$schema
)
private
function
partitionSchema
(
Schema
$schema
)
:
array
{
return
[
$this
->
extractSchemaFederation
(
$schema
,
false
),
...
...
@@ -167,13 +167,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
}
/**
* @param bool $isFederation
*
* @return Schema
*
* @throws RuntimeException
*/
private
function
extractSchemaFederation
(
Schema
$schema
,
$isFederation
)
private
function
extractSchemaFederation
(
Schema
$schema
,
bool
$isFederation
)
:
Schema
{
$partitionedSchema
=
clone
$schema
;
...
...
@@ -204,7 +200,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
*
* @return string[]
*/
private
function
work
(
Schema
$schema
,
Closure
$operation
)
private
function
work
(
Schema
$schema
,
Closure
$operation
)
:
array
{
[
$global
,
$federation
]
=
$this
->
partitionSchema
(
$schema
);
$sql
=
[];
...
...
@@ -235,10 +231,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
return
$sql
;
}
/**
* @return string
*/
private
function
getFederationTypeDefaultValue
()
private
function
getFederationTypeDefaultValue
()
:
string
{
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
...
...
@@ -259,10 +252,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
return
$defaultValue
;
}
/**
* @return string
*/
private
function
getCreateFederationStatement
()
private
function
getCreateFederationStatement
()
:
string
{
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
$federationTypeSql
=
$federationType
->
getSQLDeclaration
([],
$this
->
conn
->
getDatabasePlatform
());
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
View file @
9e2a9a40
...
...
@@ -35,7 +35,7 @@ class SQLAzureShardManager implements ShardManager
/** @var Connection */
private
$conn
;
/** @var
string|null
*/
/** @var
mixed
*/
private
$currentDistributionValue
;
/**
...
...
@@ -66,50 +66,40 @@ class SQLAzureShardManager implements ShardManager
/**
* Gets the name of the federation.
*
* @return string
*/
public
function
getFederationName
()
public
function
getFederationName
()
:
string
{
return
$this
->
federationName
;
}
/**
* Gets the distribution key.
*
* @return string
*/
public
function
getDistributionKey
()
public
function
getDistributionKey
()
:
string
{
return
$this
->
distributionKey
;
}
/**
* Gets the Doctrine Type name used for the distribution.
*
* @return string
*/
public
function
getDistributionType
()
public
function
getDistributionType
()
:
string
{
return
$this
->
distributionType
;
}
/**
* Sets Enabled/Disable filtering on the fly.
*
* @param bool $flag
*
* @return void
*/
public
function
setFilteringEnabled
(
$flag
)
public
function
setFilteringEnabled
(
bool
$flag
)
:
void
{
$this
->
filteringEnabled
=
(
bool
)
$flag
;
$this
->
filteringEnabled
=
$flag
;
}
/**
* {@inheritDoc}
*/
public
function
selectGlobal
()
public
function
selectGlobal
()
:
void
{
if
(
$this
->
conn
->
isTransactionActive
())
{
throw
ActiveTransaction
::
new
();
...
...
@@ -123,7 +113,7 @@ class SQLAzureShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
selectShard
(
$distributionValue
)
public
function
selectShard
(
$distributionValue
)
:
void
{
if
(
$this
->
conn
->
isTransactionActive
())
{
throw
ActiveTransaction
::
new
();
...
...
@@ -153,7 +143,7 @@ class SQLAzureShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
getShards
()
public
function
getShards
()
:
array
{
$sql
=
'SELECT member_id as id,
distribution_name as distribution_key,
...
...
@@ -169,7 +159,7 @@ class SQLAzureShardManager implements ShardManager
/**
* {@inheritDoc}
*/
public
function
queryAll
(
$sql
,
array
$params
=
[],
array
$types
=
[])
public
function
queryAll
(
string
$sql
,
array
$params
=
[],
array
$types
=
[])
:
array
{
$shards
=
$this
->
getShards
();
if
(
!
$shards
)
{
...
...
@@ -199,10 +189,8 @@ class SQLAzureShardManager implements ShardManager
* Splits Federation at a given distribution value.
*
* @param mixed $splitDistributionValue
*
* @return void
*/
public
function
splitFederation
(
$splitDistributionValue
)
public
function
splitFederation
(
$splitDistributionValue
)
:
void
{
$type
=
Type
::
getType
(
$this
->
distributionType
);
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
View file @
9e2a9a40
...
...
@@ -54,11 +54,9 @@ class MultiTenantVisitor implements Visitor
private
$distributionName
;
/**
* @param string[] $excludedTables
* @param string $tenantColumnName
* @param string|null $distributionName
* @param string[] $excludedTables
*/
public
function
__construct
(
array
$excludedTables
=
[],
$tenantColumnName
=
'tenant_id'
,
$distributionName
=
null
)
public
function
__construct
(
array
$excludedTables
=
[],
string
$tenantColumnName
=
'tenant_id'
,
?
string
$distributionName
=
null
)
{
$this
->
excludedTables
=
$excludedTables
;
$this
->
tenantColumnName
=
$tenantColumnName
;
...
...
@@ -94,13 +92,9 @@ class MultiTenantVisitor implements Visitor
}
/**
* @param Table $table
*
* @return Index
*
* @throws RuntimeException
*/
private
function
getClusteredIndex
(
$table
)
private
function
getClusteredIndex
(
Table
$table
)
:
Index
{
foreach
(
$table
->
getIndexes
()
as
$index
)
{
if
(
$index
->
isPrimary
()
&&
!
$index
->
hasFlag
(
'nonclustered'
))
{
...
...
lib/Doctrine/DBAL/Sharding/ShardManager.php
View file @
9e2a9a40
...
...
@@ -27,26 +27,22 @@ interface ShardManager
*
* This is the default database that is connected when no shard is
* selected.
*
* @return void
*/
public
function
selectGlobal
();
public
function
selectGlobal
()
:
void
;
/**
* Selects the shard against which the queries after this statement will be issued.
*
* @param string $distributionValue
*
* @return void
* @param mixed $distributionValue
*
* @throws ShardingException If no value is passed as shard identifier.
*/
public
function
selectShard
(
$distributionValue
);
public
function
selectShard
(
$distributionValue
)
:
void
;
/**
* Gets the distribution value currently used for sharding.
*
* @return
string|null
* @return
mixed
*/
public
function
getCurrentDistributionValue
();
...
...
@@ -58,7 +54,7 @@ interface ShardManager
*
* @return mixed[][]
*/
public
function
getShards
();
public
function
getShards
()
:
array
;
/**
* Queries all shards in undefined order and return the results appended to
...
...
@@ -66,11 +62,10 @@ interface ShardManager
*
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
*
* @param string $sql
* @param mixed[] $params
* @param int[]|string[] $types
*
* @return mixed[]
*/
public
function
queryAll
(
$sql
,
array
$params
,
array
$types
)
;
public
function
queryAll
(
string
$sql
,
array
$params
,
array
$types
)
:
array
;
}
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